18#ifndef INCLUDE_NLOHMANN_JSON_HPP_
19#define INCLUDE_NLOHMANN_JSON_HPP_
24#include <initializer_list>
60#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
61 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
62 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 12 || NLOHMANN_JSON_VERSION_PATCH != 0
63 #warning "Already included a different version of the library!"
68#define NLOHMANN_JSON_VERSION_MAJOR 3
69#define NLOHMANN_JSON_VERSION_MINOR 12
70#define NLOHMANN_JSON_VERSION_PATCH 0
72#ifndef JSON_DIAGNOSTICS
73 #define JSON_DIAGNOSTICS 0
76#ifndef JSON_DIAGNOSTIC_POSITIONS
77 #define JSON_DIAGNOSTIC_POSITIONS 0
80#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
81 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
85 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
87 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
90#if JSON_DIAGNOSTIC_POSITIONS
91 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS _dp
93 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS
96#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
97 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
99 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
102#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
103 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
107#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) json_abi ## a ## b ## c
108#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b, c) \
109 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c)
111#define NLOHMANN_JSON_ABI_TAGS \
112 NLOHMANN_JSON_ABI_TAGS_CONCAT( \
113 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
114 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON, \
115 NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS)
118#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
119 _v ## major ## _ ## minor ## _ ## patch
120#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
121 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
123#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
124#define NLOHMANN_JSON_NAMESPACE_VERSION
126#define NLOHMANN_JSON_NAMESPACE_VERSION \
127 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
128 NLOHMANN_JSON_VERSION_MINOR, \
129 NLOHMANN_JSON_VERSION_PATCH)
133#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
134#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
135 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
137#ifndef NLOHMANN_JSON_NAMESPACE
138#define NLOHMANN_JSON_NAMESPACE \
139 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
140 NLOHMANN_JSON_ABI_TAGS, \
141 NLOHMANN_JSON_NAMESPACE_VERSION)
144#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
145#define NLOHMANN_JSON_NAMESPACE_BEGIN \
148 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
149 NLOHMANN_JSON_ABI_TAGS, \
150 NLOHMANN_JSON_NAMESPACE_VERSION) \
154#ifndef NLOHMANN_JSON_NAMESPACE_END
155#define NLOHMANN_JSON_NAMESPACE_END \
173#include <forward_list>
178#include <type_traits>
179#include <unordered_map>
242#include <type_traits>
287template<
class Default,
289 template<
class...>
class Op,
297template<
class Default,
template<
class...>
class Op,
class... Args>
304template<
template<
class...>
class Op,
class... Args>
307template<
template<
class...>
class Op,
class... Args>
310template<
template<
class...>
class Op,
class... Args>
313template<
class Default,
template<
class...>
class Op,
class... Args>
316template<
class Default,
template<
class...>
class Op,
class... Args>
319template<
class Expected,
template<
class...>
class Op,
class... Args>
322template<
class To,
template<
class...>
class Op,
class... Args>
324 std::is_convertible<
detected_t<Op, Args...>, To>;
345#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
346#if defined(JSON_HEDLEY_VERSION)
347 #undef JSON_HEDLEY_VERSION
349#define JSON_HEDLEY_VERSION 15
351#if defined(JSON_HEDLEY_STRINGIFY_EX)
352 #undef JSON_HEDLEY_STRINGIFY_EX
354#define JSON_HEDLEY_STRINGIFY_EX(x) #x
356#if defined(JSON_HEDLEY_STRINGIFY)
357 #undef JSON_HEDLEY_STRINGIFY
359#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
361#if defined(JSON_HEDLEY_CONCAT_EX)
362 #undef JSON_HEDLEY_CONCAT_EX
364#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
366#if defined(JSON_HEDLEY_CONCAT)
367 #undef JSON_HEDLEY_CONCAT
369#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
371#if defined(JSON_HEDLEY_CONCAT3_EX)
372 #undef JSON_HEDLEY_CONCAT3_EX
374#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
376#if defined(JSON_HEDLEY_CONCAT3)
377 #undef JSON_HEDLEY_CONCAT3
379#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
381#if defined(JSON_HEDLEY_VERSION_ENCODE)
382 #undef JSON_HEDLEY_VERSION_ENCODE
384#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
386#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
387 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
389#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
391#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
392 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
394#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
396#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
397 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
399#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
401#if defined(JSON_HEDLEY_GNUC_VERSION)
402 #undef JSON_HEDLEY_GNUC_VERSION
404#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
405 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
406#elif defined(__GNUC__)
407 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
410#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
411 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
413#if defined(JSON_HEDLEY_GNUC_VERSION)
414 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
416 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
419#if defined(JSON_HEDLEY_MSVC_VERSION)
420 #undef JSON_HEDLEY_MSVC_VERSION
422#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
423 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
424#elif defined(_MSC_FULL_VER) && !defined(__ICL)
425 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
426#elif defined(_MSC_VER) && !defined(__ICL)
427 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
430#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
431 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
433#if !defined(JSON_HEDLEY_MSVC_VERSION)
434 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
435#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
436 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
437#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
438 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
440 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
443#if defined(JSON_HEDLEY_INTEL_VERSION)
444 #undef JSON_HEDLEY_INTEL_VERSION
446#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
447 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
448#elif defined(__INTEL_COMPILER) && !defined(__ICL)
449 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
452#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
453 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
455#if defined(JSON_HEDLEY_INTEL_VERSION)
456 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
458 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
461#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
462 #undef JSON_HEDLEY_INTEL_CL_VERSION
464#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
465 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
468#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
469 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
471#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
472 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
474 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
477#if defined(JSON_HEDLEY_PGI_VERSION)
478 #undef JSON_HEDLEY_PGI_VERSION
480#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
481 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
484#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
485 #undef JSON_HEDLEY_PGI_VERSION_CHECK
487#if defined(JSON_HEDLEY_PGI_VERSION)
488 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
490 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
493#if defined(JSON_HEDLEY_SUNPRO_VERSION)
494 #undef JSON_HEDLEY_SUNPRO_VERSION
496#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
497 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
498#elif defined(__SUNPRO_C)
499 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
500#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
501 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
502#elif defined(__SUNPRO_CC)
503 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
506#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
507 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
509#if defined(JSON_HEDLEY_SUNPRO_VERSION)
510 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
512 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
515#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
516 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
518#if defined(__EMSCRIPTEN__)
519 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
522#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
523 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
525#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
526 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
528 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
531#if defined(JSON_HEDLEY_ARM_VERSION)
532 #undef JSON_HEDLEY_ARM_VERSION
534#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
535 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
536#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
537 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
540#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
541 #undef JSON_HEDLEY_ARM_VERSION_CHECK
543#if defined(JSON_HEDLEY_ARM_VERSION)
544 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
546 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
549#if defined(JSON_HEDLEY_IBM_VERSION)
550 #undef JSON_HEDLEY_IBM_VERSION
552#if defined(__ibmxl__)
553 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
554#elif defined(__xlC__) && defined(__xlC_ver__)
555 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
556#elif defined(__xlC__)
557 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
560#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
561 #undef JSON_HEDLEY_IBM_VERSION_CHECK
563#if defined(JSON_HEDLEY_IBM_VERSION)
564 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
566 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
569#if defined(JSON_HEDLEY_TI_VERSION)
570 #undef JSON_HEDLEY_TI_VERSION
573 defined(__TI_COMPILER_VERSION__) && \
575 defined(__TMS470__) || defined(__TI_ARM__) || \
576 defined(__MSP430__) || \
577 defined(__TMS320C2000__) \
579#if (__TI_COMPILER_VERSION__ >= 16000000)
580 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
584#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
585 #undef JSON_HEDLEY_TI_VERSION_CHECK
587#if defined(JSON_HEDLEY_TI_VERSION)
588 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
590 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
593#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
594 #undef JSON_HEDLEY_TI_CL2000_VERSION
596#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
597 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
600#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
601 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
603#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
604 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
606 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
609#if defined(JSON_HEDLEY_TI_CL430_VERSION)
610 #undef JSON_HEDLEY_TI_CL430_VERSION
612#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
613 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
616#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
617 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
619#if defined(JSON_HEDLEY_TI_CL430_VERSION)
620 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
622 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
625#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
626 #undef JSON_HEDLEY_TI_ARMCL_VERSION
628#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
629 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
632#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
633 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
635#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
636 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
638 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
641#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
642 #undef JSON_HEDLEY_TI_CL6X_VERSION
644#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
645 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
648#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
649 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
651#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
652 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
654 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
657#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
658 #undef JSON_HEDLEY_TI_CL7X_VERSION
660#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
661 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
664#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
665 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
667#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
668 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
670 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
673#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
674 #undef JSON_HEDLEY_TI_CLPRU_VERSION
676#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
677 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
680#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
681 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
683#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
684 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
686 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
689#if defined(JSON_HEDLEY_CRAY_VERSION)
690 #undef JSON_HEDLEY_CRAY_VERSION
693 #if defined(_RELEASE_PATCHLEVEL)
694 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
696 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
700#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
701 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
703#if defined(JSON_HEDLEY_CRAY_VERSION)
704 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
706 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
709#if defined(JSON_HEDLEY_IAR_VERSION)
710 #undef JSON_HEDLEY_IAR_VERSION
712#if defined(__IAR_SYSTEMS_ICC__)
714 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
716 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
720#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
721 #undef JSON_HEDLEY_IAR_VERSION_CHECK
723#if defined(JSON_HEDLEY_IAR_VERSION)
724 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
726 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
729#if defined(JSON_HEDLEY_TINYC_VERSION)
730 #undef JSON_HEDLEY_TINYC_VERSION
732#if defined(__TINYC__)
733 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
736#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
737 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
739#if defined(JSON_HEDLEY_TINYC_VERSION)
740 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
742 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
745#if defined(JSON_HEDLEY_DMC_VERSION)
746 #undef JSON_HEDLEY_DMC_VERSION
749 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
752#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
753 #undef JSON_HEDLEY_DMC_VERSION_CHECK
755#if defined(JSON_HEDLEY_DMC_VERSION)
756 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
758 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
761#if defined(JSON_HEDLEY_COMPCERT_VERSION)
762 #undef JSON_HEDLEY_COMPCERT_VERSION
764#if defined(__COMPCERT_VERSION__)
765 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
768#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
769 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
771#if defined(JSON_HEDLEY_COMPCERT_VERSION)
772 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
774 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
777#if defined(JSON_HEDLEY_PELLES_VERSION)
778 #undef JSON_HEDLEY_PELLES_VERSION
781 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
784#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
785 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
787#if defined(JSON_HEDLEY_PELLES_VERSION)
788 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
790 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
793#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
794 #undef JSON_HEDLEY_MCST_LCC_VERSION
796#if defined(__LCC__) && defined(__LCC_MINOR__)
797 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
800#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
801 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
803#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
804 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
806 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
809#if defined(JSON_HEDLEY_GCC_VERSION)
810 #undef JSON_HEDLEY_GCC_VERSION
813 defined(JSON_HEDLEY_GNUC_VERSION) && \
814 !defined(__clang__) && \
815 !defined(JSON_HEDLEY_INTEL_VERSION) && \
816 !defined(JSON_HEDLEY_PGI_VERSION) && \
817 !defined(JSON_HEDLEY_ARM_VERSION) && \
818 !defined(JSON_HEDLEY_CRAY_VERSION) && \
819 !defined(JSON_HEDLEY_TI_VERSION) && \
820 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
821 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
822 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
823 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
824 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
825 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
826 !defined(__COMPCERT__) && \
827 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
828 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
831#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
832 #undef JSON_HEDLEY_GCC_VERSION_CHECK
834#if defined(JSON_HEDLEY_GCC_VERSION)
835 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
837 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
840#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
841 #undef JSON_HEDLEY_HAS_ATTRIBUTE
844 defined(__has_attribute) && \
846 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
848# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
850# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
853#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
854 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
856#if defined(__has_attribute)
857 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
859 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
862#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
863 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
865#if defined(__has_attribute)
866 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
868 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
871#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
872 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
875 defined(__has_cpp_attribute) && \
876 defined(__cplusplus) && \
877 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
878 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
880 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
883#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
884 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
886#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
887 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
889 !defined(JSON_HEDLEY_PGI_VERSION) && \
890 !defined(JSON_HEDLEY_IAR_VERSION) && \
891 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
892 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
893 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
895 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
898#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
899 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
901#if defined(__has_cpp_attribute) && defined(__cplusplus)
902 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
904 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
907#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
908 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
910#if defined(__has_cpp_attribute) && defined(__cplusplus)
911 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
913 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
916#if defined(JSON_HEDLEY_HAS_BUILTIN)
917 #undef JSON_HEDLEY_HAS_BUILTIN
919#if defined(__has_builtin)
920 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
922 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
925#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
926 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
928#if defined(__has_builtin)
929 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
931 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
934#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
935 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
937#if defined(__has_builtin)
938 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
940 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
943#if defined(JSON_HEDLEY_HAS_FEATURE)
944 #undef JSON_HEDLEY_HAS_FEATURE
946#if defined(__has_feature)
947 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
949 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
952#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
953 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
955#if defined(__has_feature)
956 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
958 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
961#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
962 #undef JSON_HEDLEY_GCC_HAS_FEATURE
964#if defined(__has_feature)
965 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
967 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
970#if defined(JSON_HEDLEY_HAS_EXTENSION)
971 #undef JSON_HEDLEY_HAS_EXTENSION
973#if defined(__has_extension)
974 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
976 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
979#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
980 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
982#if defined(__has_extension)
983 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
985 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
988#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
989 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
991#if defined(__has_extension)
992 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
994 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
997#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
998 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
1000#if defined(__has_declspec_attribute)
1001 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
1003 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
1006#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
1007 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
1009#if defined(__has_declspec_attribute)
1010 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1012 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1015#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1016 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1018#if defined(__has_declspec_attribute)
1019 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1021 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1024#if defined(JSON_HEDLEY_HAS_WARNING)
1025 #undef JSON_HEDLEY_HAS_WARNING
1027#if defined(__has_warning)
1028 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1030 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
1033#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1034 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1036#if defined(__has_warning)
1037 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1039 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1042#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1043 #undef JSON_HEDLEY_GCC_HAS_WARNING
1045#if defined(__has_warning)
1046 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1048 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1052 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1053 defined(__clang__) || \
1054 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1055 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1056 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1057 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1058 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1059 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1060 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1061 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1062 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1063 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1064 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1065 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1066 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1067 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1068 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1069 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1070 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1071#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1072 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1074 #define JSON_HEDLEY_PRAGMA(value)
1077#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1078 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1080#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1081 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1083#if defined(__clang__)
1084 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1085 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1086#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1087 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1088 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1089#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1090 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1091 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1093 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1094 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1095 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1096 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1097#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1098 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1099 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1101 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1102 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1103 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1104 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1105 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1106 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1107 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1108 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1109#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1110 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1111 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1113 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1114 #define JSON_HEDLEY_DIAGNOSTIC_POP
1119#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1120 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1122#if defined(__cplusplus)
1123# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1124# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1125# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1126# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1127 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1128 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1129 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1130 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1132 JSON_HEDLEY_DIAGNOSTIC_POP
1134# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1135 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1136 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1137 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1139 JSON_HEDLEY_DIAGNOSTIC_POP
1142# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1143 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1144 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1146 JSON_HEDLEY_DIAGNOSTIC_POP
1150#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1151 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1154#if defined(JSON_HEDLEY_CONST_CAST)
1155 #undef JSON_HEDLEY_CONST_CAST
1157#if defined(__cplusplus)
1158# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1160 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1161 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1162 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1163# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1164 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1165 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1167 JSON_HEDLEY_DIAGNOSTIC_POP \
1170# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1173#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1174 #undef JSON_HEDLEY_REINTERPRET_CAST
1176#if defined(__cplusplus)
1177 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1179 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1182#if defined(JSON_HEDLEY_STATIC_CAST)
1183 #undef JSON_HEDLEY_STATIC_CAST
1185#if defined(__cplusplus)
1186 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1188 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1191#if defined(JSON_HEDLEY_CPP_CAST)
1192 #undef JSON_HEDLEY_CPP_CAST
1194#if defined(__cplusplus)
1195# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1196# define JSON_HEDLEY_CPP_CAST(T, expr) \
1197 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1198 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1200 JSON_HEDLEY_DIAGNOSTIC_POP
1201# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1202# define JSON_HEDLEY_CPP_CAST(T, expr) \
1203 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1204 _Pragma("diag_suppress=Pe137") \
1205 JSON_HEDLEY_DIAGNOSTIC_POP
1207# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1210# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1213#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1214 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1216#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1217 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1218#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1219 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1220#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1221 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1222#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1223 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1224#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1225 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1226#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1227 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1228#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1229 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1230#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1231 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1233 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1234 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1235 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1236 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1237 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1238 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1239 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1240 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1241 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1242 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1243 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1244 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1245#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1246 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1247#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1248 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1249#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1250 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1251#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1252 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1254 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1257#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1258 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1260#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1261 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1262#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1263 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1264#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1265 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1266#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1267 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1268#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1269 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1270#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1271 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1273 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1274 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1275 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1276 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1277 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1278#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1279 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1280#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1281 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1282#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1283 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1285 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1288#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1289 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1291#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1292 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1293#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1294 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1295#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1296 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1297#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1298 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1299#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1300 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1301#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1302 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1303#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1304 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1305#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1306 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1308 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1309 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1310 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1311 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1312#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1313 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1314#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1315 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1317 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1320#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1321 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1323#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1324 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1325#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1326 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1327#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1328 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1330 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1333#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1334 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1336#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1337 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1338#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1339 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1340#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1341 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1342#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1343 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1345 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1348#if defined(JSON_HEDLEY_DEPRECATED)
1349 #undef JSON_HEDLEY_DEPRECATED
1351#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1352 #undef JSON_HEDLEY_DEPRECATED_FOR
1355 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1356 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1357 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1358 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1360 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1361 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1362 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1363 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1364 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1365 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1366 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1367 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1368 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1369 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1370 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1371 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1372 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1373 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1374#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1375 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1376 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1378 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1379 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1380 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1381 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1382 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1383 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1384 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1385 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1386 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1387 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1388 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1389 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1390 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1391 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1392 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1393 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1394 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1395 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1397 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1398 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1399 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1400 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1401 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1402#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1403 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1404 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1406 #define JSON_HEDLEY_DEPRECATED(since)
1407 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1410#if defined(JSON_HEDLEY_UNAVAILABLE)
1411 #undef JSON_HEDLEY_UNAVAILABLE
1414 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1415 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1416 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1417 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1418 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1420 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1423#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1424 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1426#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1427 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1430 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1431 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1432 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1433 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1434 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1435 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1436 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1437 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1438 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1439 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1440 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1441 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1442 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1443 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1444 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1445 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1446 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1447 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1448 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1449#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1450 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1451 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1452#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1453 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1454 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1455#elif defined(_Check_return_)
1456 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1457 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1459 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1460 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1463#if defined(JSON_HEDLEY_SENTINEL)
1464 #undef JSON_HEDLEY_SENTINEL
1467 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1468 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1469 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1470 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1471 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1472 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1474 #define JSON_HEDLEY_SENTINEL(position)
1477#if defined(JSON_HEDLEY_NO_RETURN)
1478 #undef JSON_HEDLEY_NO_RETURN
1480#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1481 #define JSON_HEDLEY_NO_RETURN __noreturn
1483 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1484 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1485 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1486#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1487 #define JSON_HEDLEY_NO_RETURN _Noreturn
1488#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1489 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1491 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1492 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1493 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1494 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1495 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1496 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1497 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1498 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1499 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1500 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1501 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1502 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1503 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1504 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1505 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1506 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1507 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1508 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1509#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1510 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1512 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1513 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1514 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1515#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1516 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1517#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1518 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1519#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1520 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1522 #define JSON_HEDLEY_NO_RETURN
1525#if defined(JSON_HEDLEY_NO_ESCAPE)
1526 #undef JSON_HEDLEY_NO_ESCAPE
1528#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1529 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1531 #define JSON_HEDLEY_NO_ESCAPE
1534#if defined(JSON_HEDLEY_UNREACHABLE)
1535 #undef JSON_HEDLEY_UNREACHABLE
1537#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1538 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1540#if defined(JSON_HEDLEY_ASSUME)
1541 #undef JSON_HEDLEY_ASSUME
1544 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1545 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1546 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1547 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1548#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1549 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1551 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1552 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1553 #if defined(__cplusplus)
1554 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1556 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1560 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1561 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1562 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1563 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1564 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1565 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1566 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1567 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1568#elif defined(JSON_HEDLEY_ASSUME)
1569 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1571#if !defined(JSON_HEDLEY_ASSUME)
1572 #if defined(JSON_HEDLEY_UNREACHABLE)
1573 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1575 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1578#if defined(JSON_HEDLEY_UNREACHABLE)
1580 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1581 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1582 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1584 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1587 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1589#if !defined(JSON_HEDLEY_UNREACHABLE)
1590 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1594#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1595 #pragma clang diagnostic ignored "-Wpedantic"
1597#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1598 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1600#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1601 #if defined(__clang__)
1602 #pragma clang diagnostic ignored "-Wvariadic-macros"
1603 #elif defined(JSON_HEDLEY_GCC_VERSION)
1604 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1607#if defined(JSON_HEDLEY_NON_NULL)
1608 #undef JSON_HEDLEY_NON_NULL
1611 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1612 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1613 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1614 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1615 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1617 #define JSON_HEDLEY_NON_NULL(...)
1621#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1622 #undef JSON_HEDLEY_PRINTF_FORMAT
1624#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1625 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1626#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1627 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1629 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1630 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1631 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1632 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1633 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1634 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1635 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1636 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1637 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1638 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1639 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1640 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1641 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1642 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1643 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1644 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1645 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1646 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1647#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1648 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1650 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1653#if defined(JSON_HEDLEY_CONSTEXPR)
1654 #undef JSON_HEDLEY_CONSTEXPR
1656#if defined(__cplusplus)
1657 #if __cplusplus >= 201103L
1658 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1661#if !defined(JSON_HEDLEY_CONSTEXPR)
1662 #define JSON_HEDLEY_CONSTEXPR
1665#if defined(JSON_HEDLEY_PREDICT)
1666 #undef JSON_HEDLEY_PREDICT
1668#if defined(JSON_HEDLEY_LIKELY)
1669 #undef JSON_HEDLEY_LIKELY
1671#if defined(JSON_HEDLEY_UNLIKELY)
1672 #undef JSON_HEDLEY_UNLIKELY
1674#if defined(JSON_HEDLEY_UNPREDICTABLE)
1675 #undef JSON_HEDLEY_UNPREDICTABLE
1677#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1678 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1681 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1682 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1683 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1684# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1685# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1686# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1687# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1688# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1690 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1691 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1692 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1693 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1694 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1695 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1696 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1697 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1698 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1699 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1700 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1701 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1702 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1703 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1704 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1705 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1706# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1707 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1708# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1710 double hedley_probability_ = (probability); \
1711 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1713# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1715 double hedley_probability_ = (probability); \
1716 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1718# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1719# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1721# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1722# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1723# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1724# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1725# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1727#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1728 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1731#if defined(JSON_HEDLEY_MALLOC)
1732 #undef JSON_HEDLEY_MALLOC
1735 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1736 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1737 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1738 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1739 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1740 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1741 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1742 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1743 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1744 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1745 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1746 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1747 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1748 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1749 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1750 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1751 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1752 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1753 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1754#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1755 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1757 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1758 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1759 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1761 #define JSON_HEDLEY_MALLOC
1764#if defined(JSON_HEDLEY_PURE)
1765 #undef JSON_HEDLEY_PURE
1768 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1769 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1770 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1771 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1772 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1773 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1774 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1775 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1776 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1777 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1778 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1779 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1780 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1781 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1782 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1783 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1784 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1785 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1786 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1787# define JSON_HEDLEY_PURE __attribute__((__pure__))
1788#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1789# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1790#elif defined(__cplusplus) && \
1792 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1793 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1794 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1796# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1798# define JSON_HEDLEY_PURE
1801#if defined(JSON_HEDLEY_CONST)
1802 #undef JSON_HEDLEY_CONST
1805 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1806 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1807 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1808 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1809 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1810 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1811 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1812 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1813 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1814 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1815 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1816 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1817 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1818 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1819 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1820 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1821 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1822 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1823 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1824 #define JSON_HEDLEY_CONST __attribute__((__const__))
1826 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1827 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1829 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1832#if defined(JSON_HEDLEY_RESTRICT)
1833 #undef JSON_HEDLEY_RESTRICT
1835#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1836 #define JSON_HEDLEY_RESTRICT restrict
1838 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1839 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1840 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1841 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1842 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1843 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1844 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1845 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1846 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1847 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1848 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1849 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1850 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1851 defined(__clang__) || \
1852 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1853 #define JSON_HEDLEY_RESTRICT __restrict
1854#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1855 #define JSON_HEDLEY_RESTRICT _Restrict
1857 #define JSON_HEDLEY_RESTRICT
1860#if defined(JSON_HEDLEY_INLINE)
1861 #undef JSON_HEDLEY_INLINE
1864 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1865 (defined(__cplusplus) && (__cplusplus >= 199711L))
1866 #define JSON_HEDLEY_INLINE inline
1868 defined(JSON_HEDLEY_GCC_VERSION) || \
1869 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1870 #define JSON_HEDLEY_INLINE __inline__
1872 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1873 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1874 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1875 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1876 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1877 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1878 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1879 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1880 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1881 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1882 #define JSON_HEDLEY_INLINE __inline
1884 #define JSON_HEDLEY_INLINE
1887#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1888 #undef JSON_HEDLEY_ALWAYS_INLINE
1891 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1892 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1893 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1894 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1895 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1896 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1897 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1898 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1899 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1900 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1901 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1902 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1903 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1904 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1905 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1906 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1907 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1908 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1909 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1910# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1912 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1913 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1914# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1915#elif defined(__cplusplus) && \
1917 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1918 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1919 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1920 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1921 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1922 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1924# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1925#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1926# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1928# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1931#if defined(JSON_HEDLEY_NEVER_INLINE)
1932 #undef JSON_HEDLEY_NEVER_INLINE
1935 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1936 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1937 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1938 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1939 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1940 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1941 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1942 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1943 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1944 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1945 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1946 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1947 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1948 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1949 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1950 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1951 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1952 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1953 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1954 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1956 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1957 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1958 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1959#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1960 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1961#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1962 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1963#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1964 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1965#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1966 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1967#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1968 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1970 #define JSON_HEDLEY_NEVER_INLINE
1973#if defined(JSON_HEDLEY_PRIVATE)
1974 #undef JSON_HEDLEY_PRIVATE
1976#if defined(JSON_HEDLEY_PUBLIC)
1977 #undef JSON_HEDLEY_PUBLIC
1979#if defined(JSON_HEDLEY_IMPORT)
1980 #undef JSON_HEDLEY_IMPORT
1982#if defined(_WIN32) || defined(__CYGWIN__)
1983# define JSON_HEDLEY_PRIVATE
1984# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1985# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1988 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1989 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1990 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1991 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1992 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1993 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1995 defined(__TI_EABI__) && \
1997 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1998 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
2001 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2002# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
2003# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
2005# define JSON_HEDLEY_PRIVATE
2006# define JSON_HEDLEY_PUBLIC
2008# define JSON_HEDLEY_IMPORT extern
2011#if defined(JSON_HEDLEY_NO_THROW)
2012 #undef JSON_HEDLEY_NO_THROW
2015 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2016 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2017 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2018 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2019 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2021 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2022 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2023 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2024 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2026 #define JSON_HEDLEY_NO_THROW
2029#if defined(JSON_HEDLEY_FALL_THROUGH)
2030 #undef JSON_HEDLEY_FALL_THROUGH
2033 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2034 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2035 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2036 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2037#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2038 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2039#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2040 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2041#elif defined(__fallthrough)
2042 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2044 #define JSON_HEDLEY_FALL_THROUGH
2047#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2048 #undef JSON_HEDLEY_RETURNS_NON_NULL
2051 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2052 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2053 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2054 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2055#elif defined(_Ret_notnull_)
2056 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2058 #define JSON_HEDLEY_RETURNS_NON_NULL
2061#if defined(JSON_HEDLEY_ARRAY_PARAM)
2062 #undef JSON_HEDLEY_ARRAY_PARAM
2065 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2066 !defined(__STDC_NO_VLA__) && \
2067 !defined(__cplusplus) && \
2068 !defined(JSON_HEDLEY_PGI_VERSION) && \
2069 !defined(JSON_HEDLEY_TINYC_VERSION)
2070 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2072 #define JSON_HEDLEY_ARRAY_PARAM(name)
2075#if defined(JSON_HEDLEY_IS_CONSTANT)
2076 #undef JSON_HEDLEY_IS_CONSTANT
2078#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2079 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2083#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2084 #undef JSON_HEDLEY_IS_CONSTEXPR_
2087 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2088 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2089 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2090 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2091 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2092 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2093 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2094 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2095 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2096 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2097 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2099#if !defined(__cplusplus)
2101 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2102 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2103 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2104 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2105 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2106 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2107 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2108#if defined(__INTPTR_TYPE__)
2109 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2112 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2116 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2117 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2118 !defined(JSON_HEDLEY_PGI_VERSION) && \
2119 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2120 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2121 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2122 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2123 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2124 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2125#if defined(__INTPTR_TYPE__)
2126 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2129 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2132 defined(JSON_HEDLEY_GCC_VERSION) || \
2133 defined(JSON_HEDLEY_INTEL_VERSION) || \
2134 defined(JSON_HEDLEY_TINYC_VERSION) || \
2135 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2136 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2137 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2138 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2139 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2140 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2142# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2146 ((void*) ((expr) * 0L) ) : \
2147((struct { char v[sizeof(void) * 2]; } *) 1) \
2153#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2154 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2155 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2157 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2159 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2160 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2162 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2165#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2166 #undef JSON_HEDLEY_BEGIN_C_DECLS
2168#if defined(JSON_HEDLEY_END_C_DECLS)
2169 #undef JSON_HEDLEY_END_C_DECLS
2171#if defined(JSON_HEDLEY_C_DECL)
2172 #undef JSON_HEDLEY_C_DECL
2174#if defined(__cplusplus)
2175 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2176 #define JSON_HEDLEY_END_C_DECLS }
2177 #define JSON_HEDLEY_C_DECL extern "C"
2179 #define JSON_HEDLEY_BEGIN_C_DECLS
2180 #define JSON_HEDLEY_END_C_DECLS
2181 #define JSON_HEDLEY_C_DECL
2184#if defined(JSON_HEDLEY_STATIC_ASSERT)
2185 #undef JSON_HEDLEY_STATIC_ASSERT
2188 !defined(__cplusplus) && ( \
2189 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2190 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2191 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2192 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2193 defined(_Static_assert) \
2195# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2197 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2198 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2199 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2200# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2202# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2205#if defined(JSON_HEDLEY_NULL)
2206 #undef JSON_HEDLEY_NULL
2208#if defined(__cplusplus)
2209 #if __cplusplus >= 201103L
2210 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2212 #define JSON_HEDLEY_NULL NULL
2214 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2217 #define JSON_HEDLEY_NULL NULL
2219 #define JSON_HEDLEY_NULL ((void*) 0)
2222#if defined(JSON_HEDLEY_MESSAGE)
2223 #undef JSON_HEDLEY_MESSAGE
2225#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2226# define JSON_HEDLEY_MESSAGE(msg) \
2227 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2228 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2229 JSON_HEDLEY_PRAGMA(message msg) \
2230 JSON_HEDLEY_DIAGNOSTIC_POP
2232 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2233 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2234# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2235#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2236# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2237#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2238# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2239#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2240# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2242# define JSON_HEDLEY_MESSAGE(msg)
2245#if defined(JSON_HEDLEY_WARNING)
2246 #undef JSON_HEDLEY_WARNING
2248#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2249# define JSON_HEDLEY_WARNING(msg) \
2250 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2251 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2252 JSON_HEDLEY_PRAGMA(clang warning msg) \
2253 JSON_HEDLEY_DIAGNOSTIC_POP
2255 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2256 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2257 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2258# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2260 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2261 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2262# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2264# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2267#if defined(JSON_HEDLEY_REQUIRE)
2268 #undef JSON_HEDLEY_REQUIRE
2270#if defined(JSON_HEDLEY_REQUIRE_MSG)
2271 #undef JSON_HEDLEY_REQUIRE_MSG
2273#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2274# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2275# define JSON_HEDLEY_REQUIRE(expr) \
2276 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2277 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2278 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2279 JSON_HEDLEY_DIAGNOSTIC_POP
2280# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2281 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2282 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2283 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2284 JSON_HEDLEY_DIAGNOSTIC_POP
2286# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2287# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2290# define JSON_HEDLEY_REQUIRE(expr)
2291# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2294#if defined(JSON_HEDLEY_FLAGS)
2295 #undef JSON_HEDLEY_FLAGS
2297#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2298 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2300 #define JSON_HEDLEY_FLAGS
2303#if defined(JSON_HEDLEY_FLAGS_CAST)
2304 #undef JSON_HEDLEY_FLAGS_CAST
2306#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2307# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2308 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2309 _Pragma("warning(disable:188)") \
2311 JSON_HEDLEY_DIAGNOSTIC_POP \
2314# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2317#if defined(JSON_HEDLEY_EMPTY_BASES)
2318 #undef JSON_HEDLEY_EMPTY_BASES
2321 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2322 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2323 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2325 #define JSON_HEDLEY_EMPTY_BASES
2330#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2331 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2333#if defined(__clang__)
2334 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2336 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2339#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2340 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2342#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2344#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2345 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2347#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2349#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2350 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2352#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2354#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2355 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2357#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2359#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2360 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2362#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2364#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2365 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2367#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2369#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2370 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2372#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2384#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2385 #if defined(__clang__)
2386 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2387 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2389 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2390 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2391 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2398#if !defined(JSON_HAS_CPP_23) && !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2399 #if (defined(__cplusplus) && __cplusplus > 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202002L)
2400 #define JSON_HAS_CPP_23
2401 #define JSON_HAS_CPP_20
2402 #define JSON_HAS_CPP_17
2403 #define JSON_HAS_CPP_14
2404 #elif (defined(__cplusplus) && __cplusplus > 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L)
2405 #define JSON_HAS_CPP_20
2406 #define JSON_HAS_CPP_17
2407 #define JSON_HAS_CPP_14
2408 #elif (defined(__cplusplus) && __cplusplus > 201402L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2409 #define JSON_HAS_CPP_17
2410 #define JSON_HAS_CPP_14
2411 #elif (defined(__cplusplus) && __cplusplus > 201103L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2412 #define JSON_HAS_CPP_14
2415 #define JSON_HAS_CPP_11
2419 #if __has_include(<version>)
2424#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2425 #ifdef JSON_HAS_CPP_17
2426 #if defined(__cpp_lib_filesystem)
2427 #define JSON_HAS_FILESYSTEM 1
2428 #elif defined(__cpp_lib_experimental_filesystem)
2429 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2430 #elif !defined(__has_include)
2431 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2432 #elif __has_include(<filesystem>)
2433 #define JSON_HAS_FILESYSTEM 1
2434 #elif __has_include(<experimental/filesystem>)
2435 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2439 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2440 #undef JSON_HAS_FILESYSTEM
2441 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2445 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2446 #undef JSON_HAS_FILESYSTEM
2447 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2451 #if defined(__clang_major__) && __clang_major__ < 7
2452 #undef JSON_HAS_FILESYSTEM
2453 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2457 #if defined(_MSC_VER) && _MSC_VER < 1914
2458 #undef JSON_HAS_FILESYSTEM
2459 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2463 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2464 #undef JSON_HAS_FILESYSTEM
2465 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2469 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2470 #undef JSON_HAS_FILESYSTEM
2471 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2476#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2477 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2480#ifndef JSON_HAS_FILESYSTEM
2481 #define JSON_HAS_FILESYSTEM 0
2484#ifndef JSON_HAS_THREE_WAY_COMPARISON
2485 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2486 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2487 #define JSON_HAS_THREE_WAY_COMPARISON 1
2489 #define JSON_HAS_THREE_WAY_COMPARISON 0
2493#ifndef JSON_HAS_RANGES
2495 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2496 #define JSON_HAS_RANGES 0
2497 #elif defined(__cpp_lib_ranges)
2498 #define JSON_HAS_RANGES 1
2500 #define JSON_HAS_RANGES 0
2504#ifndef JSON_HAS_STATIC_RTTI
2505 #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
2506 #define JSON_HAS_STATIC_RTTI 1
2508 #define JSON_HAS_STATIC_RTTI 0
2512#ifdef JSON_HAS_CPP_17
2513 #define JSON_INLINE_VARIABLE inline
2515 #define JSON_INLINE_VARIABLE
2518#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2519 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2521 #define JSON_NO_UNIQUE_ADDRESS
2525#if defined(__clang__)
2526 #pragma clang diagnostic push
2527 #pragma clang diagnostic ignored "-Wdocumentation"
2528 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2532#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2533 #define JSON_THROW(exception) throw exception
2534 #define JSON_TRY try
2535 #define JSON_CATCH(exception) catch(exception)
2536 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2539 #define JSON_THROW(exception) std::abort()
2540 #define JSON_TRY if(true)
2541 #define JSON_CATCH(exception) if(false)
2542 #define JSON_INTERNAL_CATCH(exception) if(false)
2546#if defined(JSON_THROW_USER)
2548 #define JSON_THROW JSON_THROW_USER
2550#if defined(JSON_TRY_USER)
2552 #define JSON_TRY JSON_TRY_USER
2554#if defined(JSON_CATCH_USER)
2556 #define JSON_CATCH JSON_CATCH_USER
2557 #undef JSON_INTERNAL_CATCH
2558 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2560#if defined(JSON_INTERNAL_CATCH_USER)
2561 #undef JSON_INTERNAL_CATCH
2562 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2566#if !defined(JSON_ASSERT)
2568 #define JSON_ASSERT(x) assert(x)
2572#if defined(JSON_TESTS_PRIVATE)
2573 #define JSON_PRIVATE_UNLESS_TESTED public
2575 #define JSON_PRIVATE_UNLESS_TESTED private
2583#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2584 template<typename BasicJsonType> \
2585 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2588 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2590 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2591 auto it = std::find_if(std::begin(m), std::end(m), \
2592 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2594 return ej_pair.first == e; \
2596 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2598 template<typename BasicJsonType> \
2599 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2602 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2604 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2605 auto it = std::find_if(std::begin(m), std::end(m), \
2606 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2608 return ej_pair.second == j; \
2610 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2616#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2617 template<template<typename, typename, typename...> class ObjectType, \
2618 template<typename, typename...> class ArrayType, \
2619 class StringType, class BooleanType, class NumberIntegerType, \
2620 class NumberUnsignedType, class NumberFloatType, \
2621 template<typename> class AllocatorType, \
2622 template<typename, typename = void> class JSONSerializer, \
2624 class CustomBaseClass>
2626#define NLOHMANN_BASIC_JSON_TPL \
2627 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2628 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2629 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
2633#define NLOHMANN_JSON_EXPAND( x ) x
2634#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
2635#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2636 NLOHMANN_JSON_PASTE64, \
2637 NLOHMANN_JSON_PASTE63, \
2638 NLOHMANN_JSON_PASTE62, \
2639 NLOHMANN_JSON_PASTE61, \
2640 NLOHMANN_JSON_PASTE60, \
2641 NLOHMANN_JSON_PASTE59, \
2642 NLOHMANN_JSON_PASTE58, \
2643 NLOHMANN_JSON_PASTE57, \
2644 NLOHMANN_JSON_PASTE56, \
2645 NLOHMANN_JSON_PASTE55, \
2646 NLOHMANN_JSON_PASTE54, \
2647 NLOHMANN_JSON_PASTE53, \
2648 NLOHMANN_JSON_PASTE52, \
2649 NLOHMANN_JSON_PASTE51, \
2650 NLOHMANN_JSON_PASTE50, \
2651 NLOHMANN_JSON_PASTE49, \
2652 NLOHMANN_JSON_PASTE48, \
2653 NLOHMANN_JSON_PASTE47, \
2654 NLOHMANN_JSON_PASTE46, \
2655 NLOHMANN_JSON_PASTE45, \
2656 NLOHMANN_JSON_PASTE44, \
2657 NLOHMANN_JSON_PASTE43, \
2658 NLOHMANN_JSON_PASTE42, \
2659 NLOHMANN_JSON_PASTE41, \
2660 NLOHMANN_JSON_PASTE40, \
2661 NLOHMANN_JSON_PASTE39, \
2662 NLOHMANN_JSON_PASTE38, \
2663 NLOHMANN_JSON_PASTE37, \
2664 NLOHMANN_JSON_PASTE36, \
2665 NLOHMANN_JSON_PASTE35, \
2666 NLOHMANN_JSON_PASTE34, \
2667 NLOHMANN_JSON_PASTE33, \
2668 NLOHMANN_JSON_PASTE32, \
2669 NLOHMANN_JSON_PASTE31, \
2670 NLOHMANN_JSON_PASTE30, \
2671 NLOHMANN_JSON_PASTE29, \
2672 NLOHMANN_JSON_PASTE28, \
2673 NLOHMANN_JSON_PASTE27, \
2674 NLOHMANN_JSON_PASTE26, \
2675 NLOHMANN_JSON_PASTE25, \
2676 NLOHMANN_JSON_PASTE24, \
2677 NLOHMANN_JSON_PASTE23, \
2678 NLOHMANN_JSON_PASTE22, \
2679 NLOHMANN_JSON_PASTE21, \
2680 NLOHMANN_JSON_PASTE20, \
2681 NLOHMANN_JSON_PASTE19, \
2682 NLOHMANN_JSON_PASTE18, \
2683 NLOHMANN_JSON_PASTE17, \
2684 NLOHMANN_JSON_PASTE16, \
2685 NLOHMANN_JSON_PASTE15, \
2686 NLOHMANN_JSON_PASTE14, \
2687 NLOHMANN_JSON_PASTE13, \
2688 NLOHMANN_JSON_PASTE12, \
2689 NLOHMANN_JSON_PASTE11, \
2690 NLOHMANN_JSON_PASTE10, \
2691 NLOHMANN_JSON_PASTE9, \
2692 NLOHMANN_JSON_PASTE8, \
2693 NLOHMANN_JSON_PASTE7, \
2694 NLOHMANN_JSON_PASTE6, \
2695 NLOHMANN_JSON_PASTE5, \
2696 NLOHMANN_JSON_PASTE4, \
2697 NLOHMANN_JSON_PASTE3, \
2698 NLOHMANN_JSON_PASTE2, \
2699 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2700#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2701#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2702#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2703#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2704#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2705#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2706#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2707#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2708#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2709#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2710#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2711#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2712#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2713#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2714#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2715#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2716#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2717#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2718#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2719#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2720#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
2721#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
2722#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
2723#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
2724#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
2725#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
2726#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
2727#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
2728#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
2729#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2730#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2731#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2732#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2733#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2734#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2735#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2736#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2737#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2738#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
2739#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
2740#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
2741#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
2742#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
2743#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
2744#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
2745#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
2746#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
2747#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2748#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2749#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2750#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2751#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2752#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2753#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2754#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2755#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2756#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
2757#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
2758#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
2759#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
2760#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
2761#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
2762#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
2764#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2765#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2766#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1;
2774#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2775 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2776 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2777 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2778 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2786#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2787 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2788 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2789 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2790 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2798#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2799 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2800 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2808#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2809 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2810 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2811 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2812 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2820#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2821 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2822 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2823 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2824 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2832#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2833 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2834 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2842#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \
2843 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2844 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2845 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2846 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2854#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2855 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2856 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2857 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2858 friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2866#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2867 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2868 friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2876#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \
2877 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2878 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2879 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2880 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2888#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \
2889 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2890 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2891 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2892 void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast<BaseType&>(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2900#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \
2901 template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
2902 void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast<const BaseType &>(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2910#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2911 namespace detail { \
2912 using std::std_name; \
2914 template<typename... T> \
2915 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2918 namespace detail2 { \
2919 struct std_name##_tag \
2923 template<typename... T> \
2924 std_name##_tag std_name(T&&...); \
2926 template<typename... T> \
2927 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2929 template<typename... T> \
2930 struct would_call_std_##std_name \
2932 static constexpr auto const value = ::nlohmann::detail:: \
2933 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2937 template<typename... T> \
2938 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2942#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2943 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2946#if JSON_USE_IMPLICIT_CONVERSIONS
2947 #define JSON_EXPLICIT
2949 #define JSON_EXPLICIT explicit
2952#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2953 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2956#ifndef JSON_USE_GLOBAL_UDLS
2957 #define JSON_USE_GLOBAL_UDLS 1
2960#if JSON_HAS_THREE_WAY_COMPARISON
3023#if JSON_HAS_THREE_WAY_COMPARISON
3024 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
3029 static constexpr std::array<std::uint8_t, 9> order = {{
3036 const auto l_index =
static_cast<std::size_t
>(lhs);
3037 const auto r_index =
static_cast<std::size_t
>(rhs);
3038#if JSON_HAS_THREE_WAY_COMPARISON
3039 if (l_index < order.size() && r_index < order.size())
3041 return order[l_index] <=> order[r_index];
3043 return std::partial_ordering::unordered;
3045 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
3053#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
3056 return std::is_lt(lhs <=> rhs);
3094template<
typename StringType>
3096 const StringType& t)
3099 for (
auto pos = s.find(f);
3100 pos != StringType::npos;
3101 s.replace(pos, f.size(), t),
3102 pos = s.find(f, pos + t.size()))
3113template<
typename StringType>
3128template<
typename StringType>
3169 constexpr operator size_t()
const
3194#include <type_traits>
3205using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3207#ifdef JSON_HAS_CPP_14
3210using std::enable_if_t;
3211using std::index_sequence;
3212using std::make_index_sequence;
3213using std::index_sequence_for;
3218template<
bool B,
typename T =
void>
3245template <
typename T, T... Ints>
3249 static constexpr std::size_t
size() noexcept
3251 return sizeof...(Ints);
3260template <
size_t... Ints>
3266template <
typename Seq,
size_t SeqSize,
size_t Rem>
3270template <
typename T, T... Ints,
size_t SeqSize>
3276template <
typename T, T... Ints,
size_t SeqSize>
3284template <
typename T,
size_t N>
3291template <
typename T>
3306template <
typename T, T N>
3322template <
typename... Ts>
3340#ifndef JSON_HAS_CPP_17
3341 template<
typename T>
3345template<
typename T,
typename... Args>
3346constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3348 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(args))...}};
3368#include <type_traits>
3370#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
3397template<
typename It,
typename =
void>
3400template<
typename It>
3404 typename It::reference, typename It::iterator_category >>
3415template<
typename T,
typename =
void>
3494#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3495 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3520 template<
typename T =
void,
typename SFINAE =
void>
3525 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3527 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3528 class StringType = std::string,
class BooleanType = bool,
3529 class NumberIntegerType = std::int64_t,
3530 class NumberUnsignedType = std::uint64_t,
3531 class NumberFloatType = double,
3532 template<
typename U>
class AllocatorType = std::allocator,
3533 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3535 class BinaryType = std::vector<std::uint8_t>,
3536 class CustomBaseClass =
void>
3541 template<
typename RefStringType>
3552 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3597template<
typename BasicJsonContext>
3599 std::integral_constant < bool,
3600 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3601 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3642template<
typename T,
typename... Args>
3645template<
typename T,
typename... Args>
3648template<
typename T,
typename U>
3652template<
typename BasicJsonType,
typename T,
typename =
void>
3659template <
typename BasicJsonType,
typename T>
3665template<
typename BasicJsonType,
typename T>
3668 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3672 const BasicJsonType&, T&>
::value;
3677template<
typename BasicJsonType,
typename T,
typename =
void>
3680template<
typename BasicJsonType,
typename T>
3683 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3692template<
typename BasicJsonType,
typename T,
typename =
void>
3695template<
typename BasicJsonType,
typename T>
3698 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3709struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3712template<
typename BasicJsonType>
3717 using type =
typename std::conditional < has_key_compare<object_t>::value,
3721template<
typename BasicJsonType>
3753 return static_cast<int_type>(std::char_traits<char>::eof());
3777 return static_cast<int_type>(std::char_traits<char>::eof());
3781#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
3783struct char_traits<
std::byte> : std::char_traits<char>
3785 using char_type = std::byte;
3786 using int_type = uint64_t;
3788 static int_type to_int_type(char_type c)
noexcept
3790 return static_cast<int_type
>(std::to_integer<unsigned char>(c));
3793 static char_type to_char_type(int_type i)
noexcept
3795 return std::byte(
static_cast<unsigned char>(i));
3798 static constexpr int_type eof() noexcept
3800 return static_cast<int_type
>(std::char_traits<char>::eof());
3812template<
class B,
class... Bn>
3814: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
3817template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3822template <
typename T>
3825template <
typename T1,
typename T2>
3827 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3829template <
typename T1,
typename T2>
3831 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3833template <
typename... Ts>
3835 :
conjunction<is_default_constructible<Ts>...> {};
3837template <
typename... Ts>
3839 :
conjunction<is_default_constructible<Ts>...> {};
3841template <
typename T,
typename... Args>
3844template <
typename T1,
typename T2>
3847template <
typename T1,
typename T2>
3850template <
typename... Ts>
3853template <
typename... Ts>
3856template<
typename T,
typename =
void>
3878 using t_ref =
typename std::add_lvalue_reference<T>::type;
3886 static constexpr auto is_iterator_begin =
3890 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3903template<
typename T,
typename =
void>
3909template<
typename BasicJsonType,
typename CompatibleObjectType,
3913template<
typename BasicJsonType,
typename CompatibleObjectType>
3915 BasicJsonType, CompatibleObjectType,
3924 typename CompatibleObjectType::key_type>
::value &&
3926 typename CompatibleObjectType::mapped_type>
::value;
3929template<
typename BasicJsonType,
typename CompatibleObjectType>
3933template<
typename BasicJsonType,
typename ConstructibleObjectType,
3937template<
typename BasicJsonType,
typename ConstructibleObjectType>
3939 BasicJsonType, ConstructibleObjectType,
3947 (std::is_move_assignable<ConstructibleObjectType>::value ||
3948 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3950 typename object_t::key_type>
::value &&
3952 typename object_t::mapped_type,
3953 typename ConstructibleObjectType::mapped_type >
::value)) ||
3955 typename ConstructibleObjectType::mapped_type>
::value ||
3958 typename ConstructibleObjectType::mapped_type >
::value);
3961template<
typename BasicJsonType,
typename ConstructibleObjectType>
3964 ConstructibleObjectType> {};
3966template<
typename BasicJsonType,
typename CompatibleStringType>
3973template<
typename BasicJsonType,
typename ConstructibleStringType>
3977#ifdef __INTEL_COMPILER
3978 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3990template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3993template<
typename BasicJsonType,
typename CompatibleArrayType>
3995 BasicJsonType, CompatibleArrayType,
4001 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
4008template<
typename BasicJsonType,
typename CompatibleArrayType>
4012template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
4015template<
typename BasicJsonType,
typename ConstructibleArrayType>
4017 BasicJsonType, ConstructibleArrayType,
4019 typename BasicJsonType::value_type>
::value >>
4020 : std::true_type {};
4022template<
typename BasicJsonType,
typename ConstructibleArrayType>
4024 BasicJsonType, ConstructibleArrayType,
4026 typename BasicJsonType::value_type>
::value&&
4029(std::is_move_assignable<ConstructibleArrayType>::value ||
4030 std::is_copy_assignable<ConstructibleArrayType>::value)&&
4036!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
4038detected_t<range_value_t, ConstructibleArrayType >>
::value >>
4044 typename BasicJsonType::array_t::value_type>
::value ||
4052template<
typename BasicJsonType,
typename ConstructibleArrayType>
4056template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
4060template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4062 RealIntegerType, CompatibleNumberIntegerType,
4064 std::is_integral<CompatibleNumberIntegerType>
::value&&
4065 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
4073 CompatibleNumberIntegerType>
::value &&
4074 CompatibleLimits::is_integer &&
4075 RealLimits::is_signed == CompatibleLimits::is_signed;
4078template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
4081 CompatibleNumberIntegerType> {};
4083template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
4086template<
typename BasicJsonType,
typename CompatibleType>
4088 BasicJsonType, CompatibleType,
4095template<
typename BasicJsonType,
typename CompatibleType>
4099template<
typename T1,
typename T2>
4102template<
typename T1,
typename... Args>
4105template<
typename BasicJsonType,
typename T>
4108template<
typename BasicJsonType>
4111template<
typename BasicJsonType>
4116template<
template <
typename...>
class Primary,
typename T>
4119template<
template <
typename...>
class Primary,
typename... Args>
4126template<
typename Compare,
typename A,
typename B,
typename =
void>
4129template<
typename Compare,
typename A,
typename B>
4131decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
4132decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
4133>> : std::true_type {};
4140template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4144 && !(ExcludeObjectKeyType && std::is_same<KeyType,
4146 && (!RequireTransparentComparator
4147 || is_detected <detect_is_transparent, Comparator>::value)
4150 std::false_type >::type;
4158template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4162 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
4163 RequireTransparentComparator, ExcludeObjectKeyType>
::value
4166 std::false_type >::type;
4168template<
typename ObjectType,
typename KeyType>
4172template<
typename BasicJsonType,
typename KeyType>
4176 typename BasicJsonType::object_t, KeyType >
::value,
4178 std::false_type >::type;
4182template <
typename T>
4192 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
4199template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
4202 return static_cast<T
>(
value);
4205template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
4211template<
typename... Types>
4214template<
typename... Types>
4217template<
typename... Types>
4221template<
typename... Types>
4225template<
typename OfType,
typename T>
4227 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
4230template<
typename OfType,
typename T,
4231 bool OfTypeSigned = std::is_signed<OfType>::value,
4232 bool TSigned = std::is_signed<T>::value>
4235template<
typename OfType,
typename T>
4240 using CommonType =
typename std::common_type<OfType, T>::type;
4241 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4245template<
typename OfType,
typename T>
4250 using CommonType =
typename std::common_type<OfType, T>::type;
4251 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4255template<
typename OfType,
typename T>
4260 using CommonType =
typename std::common_type<OfType, T>::type;
4261 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4265template<
typename OfType,
typename T>
4270 using CommonType =
typename std::common_type<OfType, T>::type;
4271 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4272 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4276template<
typename OfType,
typename T,
4277 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
4281template<
typename OfType,
typename T>
4290template<
typename OfType,
typename T>
4299template<
typename OfType,
typename T>
4318 using TUnExt =
typename std::remove_extent<T>::type;
4319 using TUnCVExt =
typename std::remove_cv<TUnExt>::type;
4320 using TUnPtr =
typename std::remove_pointer<T>::type;
4321 using TUnCVPtr =
typename std::remove_cv<TUnPtr>::type;
4323 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
4324 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
4389template<
typename... Args>
4390inline std::size_t
concat_length(
const char* cstr,
const Args& ... rest);
4392template<
typename StringType,
typename... Args>
4393inline std::size_t
concat_length(
const StringType& str,
const Args& ... rest);
4395template<
typename... Args>
4401template<
typename... Args>
4408template<
typename StringType,
typename... Args>
4414template<
typename OutStringType>
4418template<
typename StringType,
typename Arg>
4421template<
typename StringType,
typename Arg>
4424template<
typename StringType,
typename Arg>
4427template<
typename StringType,
typename Arg>
4430template<
typename StringType,
typename Arg>
4431using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4433template<
typename StringType,
typename Arg>
4436template<
typename StringType,
typename Arg>
4437using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
4439template<
typename StringType,
typename Arg>
4442template <
typename OutStringType,
typename Arg,
typename... Args,
4443 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4445inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4447template <
typename OutStringType,
typename Arg,
typename... Args,
4448 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4451inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4453template <
typename OutStringType,
typename Arg,
typename... Args,
4454 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4458inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4460template<
typename OutStringType,
typename Arg,
typename... Args,
4462inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4464 out.append(std::forward<Arg>(arg));
4468template <
typename OutStringType,
typename Arg,
typename... Args,
4469 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4470 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
4471inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4473 out += std::forward<Arg>(arg);
4477template <
typename OutStringType,
typename Arg,
typename... Args,
4478 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4481inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4483 out.append(arg.begin(), arg.end());
4487template <
typename OutStringType,
typename Arg,
typename... Args,
4488 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4489 && !detect_string_can_append_op<OutStringType, Arg>::value
4490 && !detect_string_can_append_iter<OutStringType, Arg>::value
4491 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4492inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4494 out.append(arg.data(), arg.size());
4498template<
typename OutStringType = std::string,
typename... Args>
4518#if defined(__clang__)
4519 #pragma clang diagnostic push
4520 #pragma clang diagnostic ignored "-Wweak-vtables"
4537 const char*
what() const noexcept
override
4547 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
4549 static std::string
name(
const std::string& ename,
int id_)
4551 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
4559 template<
typename BasicJsonType>
4563 std::vector<std::string> tokens;
4564 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4566 switch (current->m_parent->type())
4570 for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
4572 if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
4574 tokens.emplace_back(std::to_string(i));
4583 for (
const auto& element : *current->m_parent->m_data.m_value.object)
4585 if (&element.second == current)
4587 tokens.emplace_back(element.first.c_str());
4612 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4613 [](
const std::string & a,
const std::string & b)
4615 return concat(a,
'/', detail::escape(b));
4618 return concat(
'(', str,
") ", get_byte_positions(leaf_element));
4620 return get_byte_positions(leaf_element);
4626 std::runtime_error m;
4627#if JSON_DIAGNOSTIC_POSITIONS
4628 template<
typename BasicJsonType>
4629 static std::string get_byte_positions(
const BasicJsonType* leaf_element)
4631 if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
4633 return concat(
"(bytes ", std::to_string(leaf_element->start_pos()),
"-", std::to_string(leaf_element->end_pos()),
") ");
4638 template<
typename BasicJsonType>
4639 static std::string get_byte_positions(
const BasicJsonType* leaf_element)
4641 static_cast<void>(leaf_element);
4661 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4662 static parse_error
create(
int id_,
const position_t& pos,
const std::string& what_arg, BasicJsonContext context)
4669 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4670 static parse_error
create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4673 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
4675 return {id_, byte_, w.c_str()};
4690 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
4693 static std::string position_string(
const position_t& pos)
4705 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4706 static invalid_iterator
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4709 return {id_, w.c_str()};
4723 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4724 static type_error
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4727 return {id_, w.c_str()};
4740 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4741 static out_of_range
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4744 return {id_, w.c_str()};
4757 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4758 static other_error
create(
int id_,
const std::string& what_arg, BasicJsonContext context)
4761 return {id_, w.c_str()};
4772#if defined(__clang__)
4773 #pragma clang diagnostic pop
4818#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4819#include <experimental/filesystem>
4823namespace std_fs = std::experimental::filesystem;
4826#elif JSON_HAS_FILESYSTEM
4827#include <filesystem>
4831namespace std_fs = std::filesystem;
4844#ifdef JSON_HAS_CPP_17
4848#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
4849 #include <string_view>
4856template<
typename BasicJsonType>
4857inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4866#ifdef JSON_HAS_CPP_17
4867template<
typename BasicJsonType,
typename T>
4868void from_json(
const BasicJsonType& j, std::optional<T>& opt)
4876 opt.emplace(j.template
get<T>());
4882template <
typename BasicJsonType,
typename ArithmeticType,
4883 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4884 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4888 switch (
static_cast<value_t>(j))
4892 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4897 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4902 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4918template<
typename BasicJsonType>
4919inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4925 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4928template<
typename BasicJsonType>
4929inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4935 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4939 typename BasicJsonType,
typename StringType,
4941 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4942 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
4943 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4944 && !is_json_ref<StringType>::value,
int > = 0 >
4952 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4955template<
typename BasicJsonType>
4956inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4961template<
typename BasicJsonType>
4962inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4967template<
typename BasicJsonType>
4968inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4973#if !JSON_DISABLE_ENUM_SERIALIZATION
4974template<
typename BasicJsonType,
typename EnumType,
4975 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4978 typename std::underlying_type<EnumType>::type val;
4980 e =
static_cast<EnumType
>(val);
4985template<
typename BasicJsonType,
typename T,
typename Allocator,
4986 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4987inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4994 std::transform(j.rbegin(), j.rend(),
4995 std::front_inserter(l), [](
const BasicJsonType & i)
4997 return i.template get<T>();
5002template<
typename BasicJsonType,
typename T,
5003 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
5004inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
5011 std::transform(j.begin(), j.end(), std::begin(l),
5012 [](
const BasicJsonType & elem)
5014 return elem.template get<T>();
5018template<
typename BasicJsonType,
typename T, std::
size_t N>
5020->
decltype(j.template
get<T>(), void())
5022 for (std::size_t i = 0; i < N; ++i)
5024 arr[i] = j.at(i).template
get<T>();
5028template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2>
5030->
decltype(j.template
get<T>(), void())
5032 for (std::size_t i1 = 0; i1 < N1; ++i1)
5034 for (std::size_t i2 = 0; i2 < N2; ++i2)
5036 arr[i1][i2] = j.at(i1).at(i2).template
get<T>();
5041template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3>
5043->
decltype(j.template
get<T>(), void())
5045 for (std::size_t i1 = 0; i1 < N1; ++i1)
5047 for (std::size_t i2 = 0; i2 < N2; ++i2)
5049 for (std::size_t i3 = 0; i3 < N3; ++i3)
5051 arr[i1][i2][i3] = j.at(i1).at(i2).at(i3).template
get<T>();
5057template<
typename BasicJsonType,
typename T, std::
size_t N1, std::
size_t N2, std::
size_t N3, std::
size_t N4>
5058auto from_json(
const BasicJsonType& j, T (&arr)[N1][N2][N3][N4])
5059->
decltype(j.template
get<T>(), void())
5061 for (std::size_t i1 = 0; i1 < N1; ++i1)
5063 for (std::size_t i2 = 0; i2 < N2; ++i2)
5065 for (std::size_t i3 = 0; i3 < N3; ++i3)
5067 for (std::size_t i4 = 0; i4 < N4; ++i4)
5069 arr[i1][i2][i3][i4] = j.at(i1).at(i2).at(i3).at(i4).template
get<T>();
5076template<
typename BasicJsonType>
5079 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
5082template<
typename BasicJsonType,
typename T, std::
size_t N>
5085->
decltype(j.template
get<T>(), void())
5087 for (std::size_t i = 0; i < N; ++i)
5089 arr[i] = j.at(i).template
get<T>();
5093template<
typename BasicJsonType,
typename ConstructibleArrayType,
5095 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
5099 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
5105 ConstructibleArrayType ret;
5106 ret.reserve(j.size());
5107 std::transform(j.begin(), j.end(),
5108 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
5114 arr = std::move(ret);
5117template<
typename BasicJsonType,
typename ConstructibleArrayType,
5119 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
5126 ConstructibleArrayType ret;
5128 j.begin(), j.end(), std::inserter(ret, end(ret)),
5129 [](
const BasicJsonType & i)
5135 arr = std::move(ret);
5138template <
typename BasicJsonType,
typename ConstructibleArrayType,
5140 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
5141 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
5143 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
5144 !is_basic_json<ConstructibleArrayType>::value,
5146auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
5159template <
typename BasicJsonType,
typename T, std::size_t... Idx >
5163 return { { std::forward<BasicJsonType>(j).at(Idx).template
get<T>()... } };
5166template <
typename BasicJsonType,
typename T, std::
size_t N >
5178template<
typename BasicJsonType>
5179inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
5186 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
5189template<
typename BasicJsonType,
typename ConstructibleObjectType,
5190 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
5191inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
5198 ConstructibleObjectType ret;
5199 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
5200 using value_type =
typename ConstructibleObjectType::value_type;
5202 inner_object->begin(), inner_object->end(),
5203 std::inserter(ret, ret.begin()),
5204 [](
typename BasicJsonType::object_t::value_type
const & p)
5206 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
5208 obj = std::move(ret);
5215template <
typename BasicJsonType,
typename ArithmeticType,
5217 std::is_arithmetic<ArithmeticType>::value&&
5218 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
5219 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
5220 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
5221 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
5223inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
5225 switch (
static_cast<value_t>(j))
5229 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
5234 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
5239 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
5244 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
5259template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
5262 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
5265template<
typename BasicJsonType>
5271template <
typename BasicJsonType,
class A1,
class A2 >
5274 return {std::forward<BasicJsonType>(j).at(0).template
get<A1>(),
5275 std::forward<BasicJsonType>(j).at(1).template
get<A2>()};
5278template<
typename BasicJsonType,
typename A1,
typename A2>
5284template<
typename BasicJsonType,
typename... Args>
5290template<
typename BasicJsonType,
typename... Args>
5296template<
typename BasicJsonType,
typename TupleRelated>
5308template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
5310 typename BasicJsonType::string_t, Key >
::value >>
5311inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
5318 for (
const auto& p : j)
5328template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5330 typename BasicJsonType::string_t, Key >
::value >>
5331inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5338 for (
const auto& p : j)
5348#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5349template<
typename BasicJsonType>
5350inline void from_json(
const BasicJsonType& j, std_fs::path& p)
5356 const auto& s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5360#if defined(__cpp_lib_char8_t) && (__cpp_lib_char8_t >= 201907L)
5361 p = std_fs::path(std::u8string_view(
reinterpret_cast<const char8_t*
>(s.data()), s.size()));
5363 p = std_fs::u8path(s);
5370 template<
typename BasicJsonType,
typename T>
5372 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
5373 ->
decltype(
from_json(j, std::forward<T>(val)))
5375 return from_json(j, std::forward<T>(val));
5381#ifndef JSON_HAS_CPP_17
5390#ifndef JSON_HAS_CPP_17
5409#ifdef JSON_HAS_CPP_17
5418#include <type_traits>
5468template<
typename StringType>
5472 using std::to_string;
5476template<
typename StringType>
5502 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >::type >::type;
5506 IteratorType anchor{};
5508 std::size_t array_index = 0;
5510 mutable std::size_t array_index_last = 0;
5519 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5521 : anchor(
std::move(it))
5522 , array_index(array_index_)
5529 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5532 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5562 return anchor == o.anchor;
5568 return anchor != o.anchor;
5576 switch (anchor.m_object->type())
5581 if (array_index != array_index_last)
5584 array_index_last = array_index;
5586 return array_index_str;
5591 return anchor.key();
5608 typename IteratorType::reference
value()
const
5610 return anchor.value();
5619 typename IteratorType::pointer container =
nullptr;
5626 : container(&cont) {}
5650template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5651auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
5658template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5659auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
5674#if defined(__clang__)
5676 #pragma clang diagnostic push
5677 #pragma clang diagnostic ignored "-Wmismatched-tags"
5679template<
typename IteratorType>
5680class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5681 :
public std::integral_constant<std::size_t, 2> {};
5683template<std::
size_t N,
typename IteratorType>
5684class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5688 get<N>(std::declval <
5689 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5691#if defined(__clang__)
5692 #pragma clang diagnostic pop
5698 template <
typename IteratorType>
5699 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5731 template<
typename BasicJsonType>
5732 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
5734 j.m_data.m_value.destroy(j.m_data.m_type);
5736 j.m_data.m_value = b;
5737 j.assert_invariant();
5744 template<
typename BasicJsonType>
5745 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5747 j.m_data.m_value.destroy(j.m_data.m_type);
5749 j.m_data.m_value = s;
5750 j.assert_invariant();
5753 template<
typename BasicJsonType>
5754 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5756 j.m_data.m_value.destroy(j.m_data.m_type);
5758 j.m_data.m_value = std::move(s);
5759 j.assert_invariant();
5762 template <
typename BasicJsonType,
typename CompatibleStringType,
5763 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
5765 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5767 j.m_data.m_value.destroy(j.m_data.m_type);
5769 j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5770 j.assert_invariant();
5777 template<
typename BasicJsonType>
5778 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5780 j.m_data.m_value.destroy(j.m_data.m_type);
5782 j.m_data.m_value =
typename BasicJsonType::binary_t(b);
5783 j.assert_invariant();
5786 template<
typename BasicJsonType>
5787 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5789 j.m_data.m_value.destroy(j.m_data.m_type);
5791 j.m_data.m_value =
typename BasicJsonType::binary_t(std::move(b));
5792 j.assert_invariant();
5799 template<
typename BasicJsonType>
5800 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5802 j.m_data.m_value.destroy(j.m_data.m_type);
5804 j.m_data.m_value = val;
5805 j.assert_invariant();
5812 template<
typename BasicJsonType>
5813 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5815 j.m_data.m_value.destroy(j.m_data.m_type);
5817 j.m_data.m_value = val;
5818 j.assert_invariant();
5825 template<
typename BasicJsonType>
5826 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5828 j.m_data.m_value.destroy(j.m_data.m_type);
5830 j.m_data.m_value = val;
5831 j.assert_invariant();
5838 template<
typename BasicJsonType>
5839 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5841 j.m_data.m_value.destroy(j.m_data.m_type);
5843 j.m_data.m_value = arr;
5845 j.assert_invariant();
5848 template<
typename BasicJsonType>
5849 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5851 j.m_data.m_value.destroy(j.m_data.m_type);
5853 j.m_data.m_value = std::move(arr);
5855 j.assert_invariant();
5858 template <
typename BasicJsonType,
typename CompatibleArrayType,
5859 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
5861 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5866 j.m_data.m_value.destroy(j.m_data.m_type);
5868 j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
5870 j.assert_invariant();
5873 template<
typename BasicJsonType>
5874 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5876 j.m_data.m_value.destroy(j.m_data.m_type);
5879 j.m_data.m_value.array->reserve(arr.size());
5880 for (
const bool x : arr)
5882 j.m_data.m_value.array->push_back(x);
5883 j.set_parent(j.m_data.m_value.array->back());
5885 j.assert_invariant();
5888 template<
typename BasicJsonType,
typename T,
5890 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5892 j.m_data.m_value.destroy(j.m_data.m_type);
5895 j.m_data.m_value.array->resize(arr.size());
5898 std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin());
5901 j.assert_invariant();
5908 template<
typename BasicJsonType>
5909 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5911 j.m_data.m_value.destroy(j.m_data.m_type);
5913 j.m_data.m_value = obj;
5915 j.assert_invariant();
5918 template<
typename BasicJsonType>
5919 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5921 j.m_data.m_value.destroy(j.m_data.m_type);
5923 j.m_data.m_value = std::move(obj);
5925 j.assert_invariant();
5928 template <
typename BasicJsonType,
typename CompatibleObjectType,
5929 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
5930 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5935 j.m_data.m_value.destroy(j.m_data.m_type);
5937 j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5939 j.assert_invariant();
5947#ifdef JSON_HAS_CPP_17
5948template<
typename BasicJsonType,
typename T,
5949 enable_if_t<std::is_constructible<BasicJsonType, T>::value,
int> = 0>
5950void to_json(BasicJsonType& j,
const std::optional<T>& opt)
noexcept
5952 if (opt.has_value())
5963template<
typename BasicJsonType,
typename T,
5965inline void to_json(BasicJsonType& j, T b)
noexcept
5970template <
typename BasicJsonType,
typename BoolRef,
5972 ((std::is_same<std::vector<bool>::reference, BoolRef>
::value
5973 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>
::value)
5974 || (std::is_same<std::vector<bool>::const_reference, BoolRef>
::value
5975 && !std::is_same <detail::uncvref_t<std::vector<bool>::const_reference>,
5976 typename BasicJsonType::boolean_t >
::value))
5977 && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
int > = 0 >
5978inline void to_json(BasicJsonType& j,
const BoolRef& b)
noexcept
5983template<
typename BasicJsonType,
typename CompatibleString,
5984 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5985inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5990template<
typename BasicJsonType>
5991inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5996template<
typename BasicJsonType,
typename FloatType,
5997 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5998inline void to_json(BasicJsonType& j, FloatType val)
noexcept
6003template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
6004 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
6005inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
6010template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
6011 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
6012inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
6017#if !JSON_DISABLE_ENUM_SERIALIZATION
6018template<
typename BasicJsonType,
typename EnumType,
6019 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
6020inline void to_json(BasicJsonType& j, EnumType e)
noexcept
6022 using underlying_type =
typename std::underlying_type<EnumType>::type;
6028template<
typename BasicJsonType>
6029inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
6034template <
typename BasicJsonType,
typename CompatibleArrayType,
6035 enable_if_t < is_compatible_array_type<BasicJsonType,
6037 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
6039 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
6040 !is_basic_json<CompatibleArrayType>::value,
6042inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
6047template<
typename BasicJsonType>
6048inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
6053template<
typename BasicJsonType,
typename T,
6054 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
6055inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
6060template<
typename BasicJsonType>
6061inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
6066template <
typename BasicJsonType,
typename CompatibleObjectType,
6067 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
6068inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
6073template<
typename BasicJsonType>
6074inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
6080 typename BasicJsonType,
typename T, std::size_t N,
6081 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
6084inline void to_json(BasicJsonType& j,
const T(&arr)[N])
6089template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
6090inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
6092 j = { p.first, p.second };
6096template<
typename BasicJsonType,
typename T,
6100 j = { {b.key(), b.value()} };
6103template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
6106 j = { std::get<Idx>(t)... };
6109template<
typename BasicJsonType,
typename Tuple>
6112 using array_t =
typename BasicJsonType::array_t;
6116template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
6117inline void to_json(BasicJsonType& j,
const T& t)
6122#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
6123#if defined(__cpp_lib_char8_t)
6124template<
typename BasicJsonType,
typename Tr,
typename Allocator>
6125inline void to_json(BasicJsonType& j,
const std::basic_string<char8_t, Tr, Allocator>& s)
6127 using OtherAllocator =
typename std::allocator_traits<Allocator>::template rebind_alloc<char>;
6128 j = std::basic_string<char, std::char_traits<char>, OtherAllocator>(s.begin(), s.end(), s.get_allocator());
6132template<
typename BasicJsonType>
6133inline void to_json(BasicJsonType& j,
const std_fs::path& p)
6143 template<
typename BasicJsonType,
typename T>
6144 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
6145 ->
decltype(
to_json(j, std::forward<T>(val)),
void())
6147 return to_json(j, std::forward<T>(val));
6152#ifndef JSON_HAS_CPP_17
6161#ifndef JSON_HAS_CPP_17
6173template<
typename ValueType,
typename>
6178 template<
typename BasicJsonType,
typename TargetType = ValueType>
6179 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
6180 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
6181 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val),
void())
6183 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
6188 template<
typename BasicJsonType,
typename TargetType = ValueType>
6193 return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
6198 template<
typename BasicJsonType,
typename TargetType = ValueType>
6199 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
6200 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
6201 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)),
void())
6203 ::nlohmann::to_json(j, std::forward<TargetType>(val));
6231template<
typename BinaryType>
6256 , m_subtype(subtype_)
6257 , m_has_subtype(true)
6263 , m_subtype(subtype_)
6264 , m_has_subtype(true)
6269 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
6270 std::tie(
static_cast<const BinaryType&
>(rhs), rhs.m_subtype, rhs.m_has_subtype);
6275 return !(rhs == *
this);
6282 m_subtype = subtype_;
6283 m_has_subtype =
true;
6290 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
6297 return m_has_subtype;
6305 m_has_subtype =
false;
6310 bool m_has_subtype =
false;
6334#include <functional>
6346inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
6348 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
6363template<
typename BasicJsonType>
6364std::size_t
hash(
const BasicJsonType& j)
6366 using string_t =
typename BasicJsonType::string_t;
6367 using number_integer_t =
typename BasicJsonType::number_integer_t;
6368 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6369 using number_float_t =
typename BasicJsonType::number_float_t;
6371 const auto type =
static_cast<std::size_t
>(j.type());
6374 case BasicJsonType::value_t::null:
6375 case BasicJsonType::value_t::discarded:
6380 case BasicJsonType::value_t::object:
6382 auto seed =
combine(type, j.size());
6383 for (
const auto& element : j.items())
6385 const auto h = std::hash<string_t> {}(element.key());
6392 case BasicJsonType::value_t::array:
6394 auto seed =
combine(type, j.size());
6395 for (
const auto& element : j)
6402 case BasicJsonType::value_t::string:
6404 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
6408 case BasicJsonType::value_t::boolean:
6410 const auto h = std::hash<bool> {}(j.template
get<bool>());
6414 case BasicJsonType::value_t::number_integer:
6420 case BasicJsonType::value_t::number_unsigned:
6426 case BasicJsonType::value_t::number_float:
6432 case BasicJsonType::value_t::binary:
6434 auto seed =
combine(type, j.get_binary().size());
6435 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
6437 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
6438 for (
const auto byte : j.get_binary())
6440 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
6477#ifdef __cpp_lib_byteswap
6501#include <type_traits>
6555 return std::fgetc(m_file);
6562 return fread(dest, 1,
sizeof(T) * count, m_file);
6590 is->clear(is->rdstate() & std::ios::eofbit);
6595 : is(&i), sb(i.rdbuf())
6604 : is(rhs.is), sb(rhs.sb)
6615 auto res = sb->sbumpc();
6619 is->clear(is->rdstate() | std::ios::eofbit);
6627 auto res =
static_cast<std::size_t
>(sb->sgetn(
reinterpret_cast<char*
>(dest),
static_cast<std::streamsize
>(count *
sizeof(T))));
6630 is->clear(is->rdstate() | std::ios::eofbit);
6637 std::istream* is =
nullptr;
6638 std::streambuf* sb =
nullptr;
6644template<
typename IteratorType>
6648 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6651 : current(
std::move(first)), end(
std::move(last))
6659 std::advance(current, 1);
6670 auto* ptr =
reinterpret_cast<char*
>(dest);
6671 for (std::size_t read_index = 0; read_index < count *
sizeof(T); ++read_index)
6675 ptr[read_index] =
static_cast<char>(*current);
6676 std::advance(current, 1);
6683 return count *
sizeof(T);
6687 IteratorType current;
6690 template<
typename BaseInputAdapter,
size_t T>
6695 return current == end;
6699template<
typename BaseInputAdapter,
size_t T>
6702template<
typename BaseInputAdapter>
6707 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6708 size_t& utf8_bytes_index,
6709 size_t& utf8_bytes_filled)
6711 utf8_bytes_index = 0;
6715 utf8_bytes[0] = std::char_traits<char>::eof();
6716 utf8_bytes_filled = 1;
6721 const auto wc = input.get_character();
6726 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6727 utf8_bytes_filled = 1;
6729 else if (wc <= 0x7FF)
6731 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6732 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6733 utf8_bytes_filled = 2;
6735 else if (wc <= 0xFFFF)
6737 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6738 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6739 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6740 utf8_bytes_filled = 3;
6742 else if (wc <= 0x10FFFF)
6744 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6745 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6746 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6747 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6748 utf8_bytes_filled = 4;
6753 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6754 utf8_bytes_filled = 1;
6760template<
typename BaseInputAdapter>
6765 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6766 size_t& utf8_bytes_index,
6767 size_t& utf8_bytes_filled)
6769 utf8_bytes_index = 0;
6773 utf8_bytes[0] = std::char_traits<char>::eof();
6774 utf8_bytes_filled = 1;
6779 const auto wc = input.get_character();
6784 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6785 utf8_bytes_filled = 1;
6787 else if (wc <= 0x7FF)
6789 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6790 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6791 utf8_bytes_filled = 2;
6793 else if (0xD800 > wc || wc >= 0xE000)
6795 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6796 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6797 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6798 utf8_bytes_filled = 3;
6804 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6805 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6806 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6807 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6808 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6809 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6810 utf8_bytes_filled = 4;
6814 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6815 utf8_bytes_filled = 1;
6823template<
typename BaseInputAdapter,
typename W
ideCharType>
6830 : base_adapter(base) {}
6835 if (utf8_bytes_index == utf8_bytes_filled)
6837 fill_buffer<sizeof(WideCharType)>();
6845 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
6846 return utf8_bytes[utf8_bytes_index++];
6857 BaseInputAdapter base_adapter;
6866 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
6869 std::size_t utf8_bytes_index = 0;
6871 std::size_t utf8_bytes_filled = 0;
6874template<
typename IteratorType,
typename Enable =
void>
6878 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6883 return adapter_type(std::move(first), std::move(last));
6897template<
typename IteratorType>
6901 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6912template<
typename IteratorType>
6916 return factory_type::create(first, last);
6929template<
typename ContainerType,
typename Enable =
void>
6932template<
typename ContainerType>
6934 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6946template<
typename ContainerType>
6959 if (file ==
nullptr)
6961 JSON_THROW(
parse_error::create(101, 0,
"attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
6980template <
typename CharT,
6981 typename std::enable_if <
6982 std::is_pointer<CharT>::value&&
6983 !std::is_array<CharT>::value&&
6984 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6985 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6991 JSON_THROW(
parse_error::create(101, 0,
"attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
6993 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
6994 const auto* ptr =
reinterpret_cast<const char*
>(b);
6998template<
typename T, std::
size_t N>
7010 template <
typename CharT,
7011 typename std::enable_if <
7012 std::is_pointer<CharT>::value&&
7013 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
7014 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
7017 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
7019 template<
class IteratorType,
7020 typename std::enable_if<
7021 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
7028 return std::move(ia);
7051#include <type_traits>
7073#include <initializer_list>
7095template<
typename BasicJsonType>
7129 return "<uninitialized>";
7131 return "true literal";
7133 return "false literal";
7135 return "null literal";
7137 return "string literal";
7141 return "number literal";
7155 return "<parse error>";
7157 return "end of input";
7159 return "'[', '{', or a literal";
7162 return "unknown token";
7172template<
typename BasicJsonType,
typename InputAdapterType>
7175 using number_integer_t =
typename BasicJsonType::number_integer_t;
7176 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
7177 using number_float_t =
typename BasicJsonType::number_float_t;
7178 using string_t =
typename BasicJsonType::string_t;
7179 using char_type =
typename InputAdapterType::char_type;
7185 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7186 : ia(
std::move(adapter))
7187 , ignore_comments(ignore_comments_)
7188 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
7205 static char get_decimal_point() noexcept
7207 const auto* loc = localeconv();
7209 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7237 const auto factors = { 12u, 8u, 4u, 0u };
7238 for (
const auto factor : factors)
7242 if (current >=
'0' && current <=
'9')
7244 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7246 else if (current >=
'A' && current <=
'F')
7248 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7250 else if (current >=
'a' && current <=
'f')
7252 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7260 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7279 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
7281 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7284 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7293 error_message =
"invalid string: ill-formed UTF-8 byte";
7330 case char_traits<char_type>::eof():
7332 error_message =
"invalid string: missing closing quote";
7333 return token_type::parse_error;
7339 return token_type::value_string;
7383 const int codepoint1 = get_codepoint();
7384 int codepoint = codepoint1;
7388 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7389 return token_type::parse_error;
7393 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7398 const int codepoint2 = get_codepoint();
7402 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7403 return token_type::parse_error;
7410 codepoint =
static_cast<int>(
7412 (
static_cast<unsigned int>(codepoint1) << 10u)
7414 +
static_cast<unsigned int>(codepoint2)
7422 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7423 return token_type::parse_error;
7428 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7429 return token_type::parse_error;
7436 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7437 return token_type::parse_error;
7442 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7445 if (codepoint < 0x80)
7448 add(
static_cast<char_int_type
>(codepoint));
7450 else if (codepoint <= 0x7FF)
7453 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7454 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7456 else if (codepoint <= 0xFFFF)
7459 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7460 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7461 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7466 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7467 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7468 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7469 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7477 error_message =
"invalid string: forbidden character after backslash";
7478 return token_type::parse_error;
7487 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7488 return token_type::parse_error;
7493 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7494 return token_type::parse_error;
7499 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7500 return token_type::parse_error;
7505 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7506 return token_type::parse_error;
7511 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7512 return token_type::parse_error;
7517 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7518 return token_type::parse_error;
7523 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7524 return token_type::parse_error;
7529 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7530 return token_type::parse_error;
7535 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7536 return token_type::parse_error;
7541 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7542 return token_type::parse_error;
7547 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7548 return token_type::parse_error;
7553 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7554 return token_type::parse_error;
7559 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7560 return token_type::parse_error;
7565 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7566 return token_type::parse_error;
7571 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7572 return token_type::parse_error;
7577 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7578 return token_type::parse_error;
7583 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7584 return token_type::parse_error;
7589 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7590 return token_type::parse_error;
7595 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7596 return token_type::parse_error;
7601 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7602 return token_type::parse_error;
7607 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7608 return token_type::parse_error;
7613 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7614 return token_type::parse_error;
7619 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7620 return token_type::parse_error;
7625 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7626 return token_type::parse_error;
7631 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7632 return token_type::parse_error;
7637 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7638 return token_type::parse_error;
7643 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7644 return token_type::parse_error;
7649 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7650 return token_type::parse_error;
7655 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7656 return token_type::parse_error;
7661 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7662 return token_type::parse_error;
7667 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7668 return token_type::parse_error;
7673 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7674 return token_type::parse_error;
7811 return token_type::parse_error;
7821 return token_type::parse_error;
7845 return token_type::parse_error;
7855 return token_type::parse_error;
7865 return token_type::parse_error;
7877 return token_type::parse_error;
7887 return token_type::parse_error;
7895 error_message =
"invalid string: ill-formed UTF-8 byte";
7896 return token_type::parse_error;
7939 error_message =
"invalid comment; missing closing '*/'";
7967 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7974 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
7976 f = std::strtof(str, endptr);
7980 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
7982 f = std::strtod(str, endptr);
7986 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
7988 f = std::strtold(str, endptr);
8031 token_type scan_number()
8038 token_type number_type = token_type::value_unsigned;
8046 goto scan_number_minus;
8052 goto scan_number_zero;
8066 goto scan_number_any1;
8076 number_type = token_type::value_integer;
8082 goto scan_number_zero;
8096 goto scan_number_any1;
8101 error_message =
"invalid number; expected digit after '-'";
8102 return token_type::parse_error;
8112 add(decimal_point_char);
8113 decimal_point_position = token_buffer.size() - 1;
8114 goto scan_number_decimal1;
8121 goto scan_number_exponent;
8125 goto scan_number_done;
8144 goto scan_number_any1;
8149 add(decimal_point_char);
8150 decimal_point_position = token_buffer.size() - 1;
8151 goto scan_number_decimal1;
8158 goto scan_number_exponent;
8162 goto scan_number_done;
8165scan_number_decimal1:
8167 number_type = token_type::value_float;
8182 goto scan_number_decimal2;
8187 error_message =
"invalid number; expected digit after '.'";
8188 return token_type::parse_error;
8192scan_number_decimal2:
8208 goto scan_number_decimal2;
8215 goto scan_number_exponent;
8219 goto scan_number_done;
8222scan_number_exponent:
8224 number_type = token_type::value_float;
8231 goto scan_number_sign;
8246 goto scan_number_any2;
8252 "invalid number; expected '+', '-', or digit after exponent";
8253 return token_type::parse_error;
8273 goto scan_number_any2;
8278 error_message =
"invalid number; expected digit after exponent sign";
8279 return token_type::parse_error;
8299 goto scan_number_any2;
8303 goto scan_number_done;
8311 char* endptr =
nullptr;
8315 if (number_type == token_type::value_unsigned)
8317 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8320 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8322 if (errno != ERANGE)
8324 value_unsigned =
static_cast<number_unsigned_t
>(x);
8325 if (value_unsigned == x)
8327 return token_type::value_unsigned;
8331 else if (number_type == token_type::value_integer)
8333 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8336 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8338 if (errno != ERANGE)
8340 value_integer =
static_cast<number_integer_t
>(x);
8341 if (value_integer == x)
8343 return token_type::value_integer;
8350 strtof(value_float, token_buffer.data(), &endptr);
8353 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8355 return token_type::value_float;
8364 token_type scan_literal(const char_type* literal_text, const std::
size_t length,
8365 token_type return_type)
8368 for (std::size_t i = 1; i < length; ++i)
8372 error_message =
"invalid literal";
8373 return token_type::parse_error;
8384 void reset() noexcept
8386 token_buffer.clear();
8387 token_string.clear();
8388 decimal_point_position = std::string::npos;
8404 ++position.chars_read_total;
8405 ++position.chars_read_current_line;
8414 current = ia.get_character();
8422 if (current ==
'\n')
8424 ++position.lines_read;
8425 position.chars_read_current_line = 0;
8443 --position.chars_read_total;
8446 if (position.chars_read_current_line == 0)
8448 if (position.lines_read > 0)
8450 --position.lines_read;
8455 --position.chars_read_current_line;
8461 token_string.pop_back();
8466 void add(char_int_type c)
8468 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8479 return value_integer;
8485 return value_unsigned;
8498 if (decimal_point_char !=
'.' && decimal_point_position != std::string::npos)
8500 token_buffer[decimal_point_position] =
'.';
8502 return token_buffer;
8522 for (
const auto c : token_string)
8524 if (
static_cast<unsigned char>(c) <=
'\x1F')
8527 std::array<char, 9> cs{{}};
8528 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8529 result += cs.data();
8534 result.push_back(
static_cast<std::string::value_type
>(c));
8545 return error_message;
8561 return get() == 0xBB &&
get() == 0xBF;
8576 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8582 if (position.chars_read_total == 0 && !
skip_bom())
8584 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8585 return token_type::parse_error;
8592 while (ignore_comments && current ==
'/')
8594 if (!scan_comment())
8596 return token_type::parse_error;
8607 return token_type::begin_array;
8609 return token_type::end_array;
8611 return token_type::begin_object;
8613 return token_type::end_object;
8615 return token_type::name_separator;
8617 return token_type::value_separator;
8622 std::array<char_type, 4> true_literal = {{
static_cast<char_type
>(
't'),
static_cast<char_type
>(
'r'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'e')}};
8623 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8627 std::array<char_type, 5> false_literal = {{
static_cast<char_type
>(
'f'),
static_cast<char_type
>(
'a'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
's'),
static_cast<char_type
>(
'e')}};
8628 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8632 std::array<char_type, 4> null_literal = {{
static_cast<char_type
>(
'n'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
'l')}};
8633 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8638 return scan_string();
8652 return scan_number();
8658 return token_type::end_of_input;
8662 error_message =
"invalid literal";
8663 return token_type::parse_error;
8669 InputAdapterType ia;
8672 const bool ignore_comments =
false;
8678 bool next_unget =
false;
8684 std::vector<char_type> token_string {};
8687 string_t token_buffer {};
8690 const char* error_message =
"";
8693 number_integer_t value_integer = 0;
8694 number_unsigned_t value_unsigned = 0;
8695 number_float_t value_float = 0;
8698 const char_int_type decimal_point_char =
'.';
8700 std::size_t decimal_point_position = std::string::npos;
8720template<
typename BasicJsonType>
8824 const std::string& last_token,
8839 return (std::numeric_limits<std::size_t>::max)();
8855template<
typename BasicJsonType,
typename InputAdapterType>
8872 : root(r), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
8884 handle_value(
nullptr);
8920 handle_value(std::move(val));
8926 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
8928#if JSON_DIAGNOSTIC_POSITIONS
8935 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
8953 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
8962#if JSON_DIAGNOSTIC_POSITIONS
8966 ref_stack.back()->end_position = m_lexer_ref->get_position();
8970 ref_stack.back()->set_parents();
8971 ref_stack.pop_back();
8977 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
8979#if JSON_DIAGNOSTIC_POSITIONS
8984 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9001#if JSON_DIAGNOSTIC_POSITIONS
9005 ref_stack.back()->end_position = m_lexer_ref->get_position();
9009 ref_stack.back()->set_parents();
9010 ref_stack.pop_back();
9014 template<
class Exception>
9016 const Exception& ex)
9019 static_cast<void>(ex);
9020 if (allow_exceptions)
9034#if JSON_DIAGNOSTIC_POSITIONS
9035 void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
9042 v.end_position = m_lexer_ref->get_position();
9049 v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
9056 v.start_position = v.end_position - 4;
9060 case value_t::string:
9063 v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
9072 case value_t::discarded:
9074 v.end_position = std::string::npos;
9075 v.start_position = v.end_position;
9079 case value_t::binary:
9080 case value_t::number_integer:
9081 case value_t::number_unsigned:
9082 case value_t::number_float:
9084 v.start_position = v.end_position - m_lexer_ref->get_string().size();
9087 case value_t::object:
9088 case value_t::array:
9108 template<
typename Value>
9110 BasicJsonType* handle_value(Value&& v)
9112 if (ref_stack.empty())
9114 root = BasicJsonType(std::forward<Value>(v));
9116#if JSON_DIAGNOSTIC_POSITIONS
9117 handle_diagnostic_positions_for_json_value(root);
9123 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9125 if (ref_stack.back()->is_array())
9127 ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v));
9129#if JSON_DIAGNOSTIC_POSITIONS
9130 handle_diagnostic_positions_for_json_value(ref_stack.back()->m_data.m_value.array->back());
9133 return &(ref_stack.back()->m_data.m_value.array->back());
9138 *object_element = BasicJsonType(std::forward<Value>(v));
9140#if JSON_DIAGNOSTIC_POSITIONS
9141 handle_diagnostic_positions_for_json_value(*object_element);
9144 return object_element;
9148 BasicJsonType& root;
9150 std::vector<BasicJsonType*> ref_stack {};
9152 BasicJsonType* object_element =
nullptr;
9154 bool errored =
false;
9156 const bool allow_exceptions =
true;
9158 lexer_t* m_lexer_ref =
nullptr;
9161template<
typename BasicJsonType,
typename InputAdapterType>
9176 const bool allow_exceptions_ =
true,
9178 : root(r), callback(
std::move(cb)), allow_exceptions(allow_exceptions_), m_lexer_ref(lexer_)
9180 keep_stack.push_back(
true);
9192 handle_value(
nullptr);
9228 handle_value(std::move(val));
9236 keep_stack.push_back(keep);
9238 auto val = handle_value(BasicJsonType::value_t::object,
true);
9239 ref_stack.push_back(val.second);
9241 if (ref_stack.back())
9244#if JSON_DIAGNOSTIC_POSITIONS
9251 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9266 BasicJsonType k = BasicJsonType(val);
9269 const bool keep = callback(
static_cast<int>(ref_stack.size()),
parse_event_t::key, k);
9270 key_keep_stack.push_back(keep);
9273 if (keep && ref_stack.back())
9275 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) = discarded);
9283 if (ref_stack.back())
9288 *ref_stack.back() = discarded;
9290#if JSON_DIAGNOSTIC_POSITIONS
9292 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9298#if JSON_DIAGNOSTIC_POSITIONS
9302 ref_stack.back()->end_position = m_lexer_ref->get_position();
9306 ref_stack.back()->set_parents();
9312 ref_stack.pop_back();
9313 keep_stack.pop_back();
9315 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
9318 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
9320 if (it->is_discarded())
9322 ref_stack.back()->erase(it);
9334 keep_stack.push_back(keep);
9336 auto val = handle_value(BasicJsonType::value_t::array,
true);
9337 ref_stack.push_back(val.second);
9339 if (ref_stack.back())
9342#if JSON_DIAGNOSTIC_POSITIONS
9349 ref_stack.back()->start_position = m_lexer_ref->get_position() - 1;
9367 if (ref_stack.back())
9373#if JSON_DIAGNOSTIC_POSITIONS
9377 ref_stack.back()->end_position = m_lexer_ref->get_position();
9381 ref_stack.back()->set_parents();
9386 *ref_stack.back() = discarded;
9388#if JSON_DIAGNOSTIC_POSITIONS
9390 handle_diagnostic_positions_for_json_value(*ref_stack.back());
9397 ref_stack.pop_back();
9398 keep_stack.pop_back();
9401 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
9403 ref_stack.back()->m_data.m_value.array->pop_back();
9409 template<
class Exception>
9411 const Exception& ex)
9414 static_cast<void>(ex);
9415 if (allow_exceptions)
9429#if JSON_DIAGNOSTIC_POSITIONS
9430 void handle_diagnostic_positions_for_json_value(BasicJsonType& v)
9437 v.end_position = m_lexer_ref->get_position();
9444 v.start_position = v.end_position - (v.m_data.m_value.boolean ? 4 : 5);
9451 v.start_position = v.end_position - 4;
9455 case value_t::string:
9458 v.start_position = v.end_position - v.m_data.m_value.string->size() - 2;
9462 case value_t::discarded:
9464 v.end_position = std::string::npos;
9465 v.start_position = v.end_position;
9469 case value_t::binary:
9470 case value_t::number_integer:
9471 case value_t::number_unsigned:
9472 case value_t::number_float:
9474 v.start_position = v.end_position - m_lexer_ref->get_string().size();
9478 case value_t::object:
9479 case value_t::array:
9508 template<
typename Value>
9509 std::pair<bool, BasicJsonType*> handle_value(Value&& v,
const bool skip_callback =
false)
9515 if (!keep_stack.back())
9517 return {
false,
nullptr};
9521 auto value = BasicJsonType(std::forward<Value>(v));
9523#if JSON_DIAGNOSTIC_POSITIONS
9524 handle_diagnostic_positions_for_json_value(value);
9528 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value, value);
9533 return {
false,
nullptr};
9536 if (ref_stack.empty())
9538 root = std::move(value);
9539 return {
true, & root};
9544 if (!ref_stack.back())
9546 return {
false,
nullptr};
9550 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
9553 if (ref_stack.back()->is_array())
9555 ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
9556 return {
true, & (ref_stack.back()->m_data.m_value.array->back())};
9563 const bool store_element = key_keep_stack.back();
9564 key_keep_stack.pop_back();
9568 return {
false,
nullptr};
9572 *object_element = std::move(value);
9573 return {
true, object_element};
9577 BasicJsonType& root;
9579 std::vector<BasicJsonType*> ref_stack {};
9581 std::vector<bool> keep_stack {};
9583 std::vector<bool> key_keep_stack {};
9585 BasicJsonType* object_element =
nullptr;
9587 bool errored =
false;
9591 const bool allow_exceptions =
true;
9593 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
9595 lexer_t* m_lexer_ref =
nullptr;
9598template<
typename BasicJsonType>
9712 decltype(std::declval<T&>().boolean(std::declval<bool>()));
9714template<
typename T,
typename Integer>
9716 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
9718template<
typename T,
typename Un
signed>
9720 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
9722template<
typename T,
typename Float,
typename String>
9724 std::declval<Float>(), std::declval<const String&>()));
9726template<
typename T,
typename String>
9728 decltype(std::declval<T&>().string(std::declval<String&>()));
9730template<
typename T,
typename Binary>
9732 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
9736 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
9738template<
typename T,
typename String>
9740 decltype(std::declval<T&>().key(std::declval<String&>()));
9747 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
9752template<
typename T,
typename Exception>
9754 std::declval<std::size_t>(), std::declval<const std::string&>(),
9755 std::declval<const Exception&>()));
9757template<
typename SAX,
typename BasicJsonType>
9762 "BasicJsonType must be of type basic_json<...>");
9764 using number_integer_t =
typename BasicJsonType::number_integer_t;
9765 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9766 using number_float_t =
typename BasicJsonType::number_float_t;
9767 using string_t =
typename BasicJsonType::string_t;
9768 using binary_t =
typename BasicJsonType::binary_t;
9769 using exception_t =
typename BasicJsonType::exception;
9788template<
typename SAX,
typename BasicJsonType>
9793 "BasicJsonType must be of type basic_json<...>");
9795 using number_integer_t =
typename BasicJsonType::number_integer_t;
9796 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9797 using number_float_t =
typename BasicJsonType::number_float_t;
9798 using string_t =
typename BasicJsonType::string_t;
9799 using binary_t =
typename BasicJsonType::binary_t;
9800 using exception_t =
typename BasicJsonType::exception;
9804 "Missing/invalid function: bool null()");
9806 "Missing/invalid function: bool boolean(bool)");
9808 "Missing/invalid function: bool boolean(bool)");
9812 "Missing/invalid function: bool number_integer(number_integer_t)");
9816 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9818 number_float_t, string_t>
::value,
9819 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9822 "Missing/invalid function: bool string(string_t&)");
9825 "Missing/invalid function: bool binary(binary_t&)");
9827 "Missing/invalid function: bool start_object(std::size_t)");
9829 "Missing/invalid function: bool key(string_t&)");
9831 "Missing/invalid function: bool end_object()");
9833 "Missing/invalid function: bool start_array(std::size_t)");
9835 "Missing/invalid function: bool end_array()");
9838 "Missing/invalid function: bool parse_error(std::size_t, const "
9839 "std::string&, const exception&)");
9873 return *
reinterpret_cast<char*
>(&num) == 1;
9883template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType, InputAdapterType>>
9886 using number_integer_t =
typename BasicJsonType::number_integer_t;
9887 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9888 using number_float_t =
typename BasicJsonType::number_float_t;
9889 using string_t =
typename BasicJsonType::string_t;
9890 using binary_t =
typename BasicJsonType::binary_t;
9891 using json_sax_t = SAX;
9892 using char_type =
typename InputAdapterType::char_type;
9924 const
bool strict = true,
9928 bool result =
false;
9933 result = parse_bson_internal();
9937 result = parse_cbor_internal(
true, tag_handler);
9941 result = parse_msgpack_internal();
9946 result = parse_ubjson_internal();
9968 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read,
9969 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9985 bool parse_bson_internal()
9987 std::int32_t document_size{};
9988 get_number<std::int32_t, true>(input_format_t::bson, document_size);
10000 return sax->end_object();
10010 bool get_bson_cstr(string_t& result)
10012 auto out = std::back_inserter(result);
10020 if (current == 0x00)
10024 *out++ =
static_cast<typename string_t::value_type
>(current);
10039 template<
typename NumberType>
10040 bool get_bson_string(
const NumberType len, string_t& result)
10044 auto last_token = get_token_string();
10045 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10046 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(len)),
"string"),
nullptr));
10049 return get_string(input_format_t::bson, len -
static_cast<NumberType
>(1), result) &&
get() != char_traits<char_type>::eof();
10061 template<
typename NumberType>
10062 bool get_bson_binary(
const NumberType len, binary_t& result)
10066 auto last_token = get_token_string();
10067 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10068 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(len)),
"binary"),
nullptr));
10072 std::uint8_t subtype{};
10073 get_number<std::uint8_t>(input_format_t::bson, subtype);
10074 result.set_subtype(subtype);
10076 return get_binary(input_format_t::bson, len, result);
10089 bool parse_bson_element_internal(
const char_int_type element_type,
10090 const std::size_t element_type_parse_position)
10092 switch (element_type)
10097 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10102 std::int32_t len{};
10104 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
10109 return parse_bson_internal();
10114 return parse_bson_array();
10119 std::int32_t len{};
10121 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
10126 return sax->boolean(
get() != 0);
10131 return sax->null();
10136 std::int32_t
value{};
10137 return get_number<std::int32_t, true>(input_format_t::bson, value) && sax->number_integer(value);
10142 std::int64_t
value{};
10143 return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value);
10148 std::uint64_t
value{};
10149 return get_number<std::uint64_t, true>(input_format_t::bson, value) && sax->number_unsigned(value);
10154 std::array<char, 3> cr{{}};
10155 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
10156 const std::string cr_str{cr.data()};
10157 return sax->parse_error(element_type_parse_position, cr_str,
10158 parse_error::create(114, element_type_parse_position,
concat(
"Unsupported BSON record type 0x", cr_str),
nullptr));
10175 bool parse_bson_element_list(
const bool is_array)
10179 while (
auto element_type =
get())
10186 const std::size_t element_type_parse_position = chars_read;
10192 if (!is_array && !sax->key(key))
10197 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
10213 bool parse_bson_array()
10215 std::int32_t document_size{};
10216 get_number<std::int32_t, true>(input_format_t::bson, document_size);
10228 return sax->end_array();
10243 bool parse_cbor_internal(
const bool get_char,
10244 const cbor_tag_handler_t tag_handler)
10246 switch (get_char ?
get() : current)
10249 case char_traits<char_type>::eof():
10277 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
10281 std::uint8_t number{};
10282 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10287 std::uint16_t number{};
10288 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10293 std::uint32_t number{};
10294 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10299 std::uint64_t number{};
10300 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
10328 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
10332 std::uint8_t number{};
10333 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
10338 std::uint16_t number{};
10339 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
10344 std::uint32_t number{};
10345 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
10350 std::uint64_t number{};
10351 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
10352 -
static_cast<number_integer_t
>(number));
10387 return get_cbor_binary(b) && sax->binary(b);
10422 return get_cbor_string(s) && sax->string(s);
10450 return get_cbor_array(
10451 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10455 std::uint8_t len{};
10456 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10461 std::uint16_t len{};
10462 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
10467 std::uint32_t len{};
10468 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10473 std::uint64_t len{};
10474 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
10505 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
10509 std::uint8_t len{};
10510 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10515 std::uint16_t len{};
10516 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
10521 std::uint32_t len{};
10522 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10527 std::uint64_t len{};
10528 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
10554 switch (tag_handler)
10556 case cbor_tag_handler_t::error:
10558 auto last_token = get_token_string();
10559 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10560 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10563 case cbor_tag_handler_t::ignore:
10570 std::uint8_t subtype_to_ignore{};
10571 get_number(input_format_t::cbor, subtype_to_ignore);
10576 std::uint16_t subtype_to_ignore{};
10577 get_number(input_format_t::cbor, subtype_to_ignore);
10582 std::uint32_t subtype_to_ignore{};
10583 get_number(input_format_t::cbor, subtype_to_ignore);
10588 std::uint64_t subtype_to_ignore{};
10589 get_number(input_format_t::cbor, subtype_to_ignore);
10595 return parse_cbor_internal(
true, tag_handler);
10598 case cbor_tag_handler_t::store:
10606 std::uint8_t subtype{};
10607 get_number(input_format_t::cbor, subtype);
10613 std::uint16_t subtype{};
10614 get_number(input_format_t::cbor, subtype);
10620 std::uint32_t subtype{};
10621 get_number(input_format_t::cbor, subtype);
10627 std::uint64_t subtype{};
10628 get_number(input_format_t::cbor, subtype);
10633 return parse_cbor_internal(
true, tag_handler);
10636 return get_cbor_binary(b) && sax->binary(b);
10646 return sax->boolean(
false);
10649 return sax->boolean(
true);
10652 return sax->null();
10656 const auto byte1_raw =
get();
10661 const auto byte2_raw =
get();
10667 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
10668 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
10678 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
10679 const double val = [&half]
10681 const int exp = (half >> 10u) & 0x1Fu;
10682 const unsigned int mant = half & 0x3FFu;
10688 return std::ldexp(mant, -24);
10691 ? std::numeric_limits<double>::infinity()
10692 : std::numeric_limits<double>::quiet_NaN();
10694 return std::ldexp(mant + 1024, exp - 25);
10697 return sax->number_float((half & 0x8000u) != 0
10698 ?
static_cast<number_float_t
>(-val)
10699 :
static_cast<number_float_t
>(val),
"");
10705 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10711 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10716 auto last_token = get_token_string();
10717 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10718 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10734 bool get_cbor_string(string_t& result)
10769 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10774 std::uint8_t len{};
10775 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10780 std::uint16_t len{};
10781 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10786 std::uint32_t len{};
10787 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10792 std::uint64_t len{};
10793 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10798 while (
get() != 0xFF)
10801 if (!get_cbor_string(chunk))
10805 result.append(chunk);
10812 auto last_token = get_token_string();
10813 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10814 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10830 bool get_cbor_binary(binary_t& result)
10865 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10870 std::uint8_t len{};
10871 return get_number(input_format_t::cbor, len) &&
10872 get_binary(input_format_t::cbor, len, result);
10877 std::uint16_t len{};
10878 return get_number(input_format_t::cbor, len) &&
10879 get_binary(input_format_t::cbor, len, result);
10884 std::uint32_t len{};
10885 return get_number(input_format_t::cbor, len) &&
10886 get_binary(input_format_t::cbor, len, result);
10891 std::uint64_t len{};
10892 return get_number(input_format_t::cbor, len) &&
10893 get_binary(input_format_t::cbor, len, result);
10898 while (
get() != 0xFF)
10901 if (!get_cbor_binary(chunk))
10905 result.insert(result.end(), chunk.begin(), chunk.end());
10912 auto last_token = get_token_string();
10913 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10914 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token),
"binary"),
nullptr));
10925 bool get_cbor_array(
const std::size_t len,
10926 const cbor_tag_handler_t tag_handler)
10935 for (std::size_t i = 0; i < len; ++i)
10945 while (
get() != 0xFF)
10954 return sax->end_array();
10963 bool get_cbor_object(
const std::size_t len,
10964 const cbor_tag_handler_t tag_handler)
10976 for (std::size_t i = 0; i < len; ++i)
10993 while (
get() != 0xFF)
11009 return sax->end_object();
11019 bool parse_msgpack_internal()
11024 case char_traits<char_type>::eof():
11156 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
11175 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11194 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
11234 return get_msgpack_string(s) && sax->string(s);
11238 return sax->null();
11241 return sax->boolean(
false);
11244 return sax->boolean(
true);
11259 return get_msgpack_binary(b) && sax->binary(b);
11265 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11271 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11276 std::uint8_t number{};
11277 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11282 std::uint16_t number{};
11283 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11288 std::uint32_t number{};
11289 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11294 std::uint64_t number{};
11295 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
11300 std::int8_t number{};
11301 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11306 std::int16_t number{};
11307 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11312 std::int32_t number{};
11313 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11318 std::int64_t number{};
11319 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
11324 std::uint16_t len{};
11325 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t
>(len));
11330 std::uint32_t len{};
11331 return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
11336 std::uint16_t len{};
11337 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t
>(len));
11342 std::uint32_t len{};
11343 return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
11379 return sax->number_integer(
static_cast<std::int8_t
>(current));
11383 auto last_token = get_token_string();
11384 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11385 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
11400 bool get_msgpack_string(string_t& result)
11443 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu, result);
11448 std::uint8_t len{};
11449 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11454 std::uint16_t len{};
11455 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11460 std::uint32_t len{};
11461 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
11466 auto last_token = get_token_string();
11467 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
11468 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
11483 bool get_msgpack_binary(binary_t& result)
11486 auto assign_and_return_true = [&result](std::int8_t subtype)
11488 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
11496 std::uint8_t len{};
11497 return get_number(input_format_t::msgpack, len) &&
11498 get_binary(input_format_t::msgpack, len, result);
11503 std::uint16_t len{};
11504 return get_number(input_format_t::msgpack, len) &&
11505 get_binary(input_format_t::msgpack, len, result);
11510 std::uint32_t len{};
11511 return get_number(input_format_t::msgpack, len) &&
11512 get_binary(input_format_t::msgpack, len, result);
11517 std::uint8_t len{};
11518 std::int8_t subtype{};
11519 return get_number(input_format_t::msgpack, len) &&
11520 get_number(input_format_t::msgpack, subtype) &&
11521 get_binary(input_format_t::msgpack, len, result) &&
11522 assign_and_return_true(subtype);
11527 std::uint16_t len{};
11528 std::int8_t subtype{};
11529 return get_number(input_format_t::msgpack, len) &&
11530 get_number(input_format_t::msgpack, subtype) &&
11531 get_binary(input_format_t::msgpack, len, result) &&
11532 assign_and_return_true(subtype);
11537 std::uint32_t len{};
11538 std::int8_t subtype{};
11539 return get_number(input_format_t::msgpack, len) &&
11540 get_number(input_format_t::msgpack, subtype) &&
11541 get_binary(input_format_t::msgpack, len, result) &&
11542 assign_and_return_true(subtype);
11547 std::int8_t subtype{};
11548 return get_number(input_format_t::msgpack, subtype) &&
11549 get_binary(input_format_t::msgpack, 1, result) &&
11550 assign_and_return_true(subtype);
11555 std::int8_t subtype{};
11556 return get_number(input_format_t::msgpack, subtype) &&
11557 get_binary(input_format_t::msgpack, 2, result) &&
11558 assign_and_return_true(subtype);
11563 std::int8_t subtype{};
11564 return get_number(input_format_t::msgpack, subtype) &&
11565 get_binary(input_format_t::msgpack, 4, result) &&
11566 assign_and_return_true(subtype);
11571 std::int8_t subtype{};
11572 return get_number(input_format_t::msgpack, subtype) &&
11573 get_binary(input_format_t::msgpack, 8, result) &&
11574 assign_and_return_true(subtype);
11579 std::int8_t subtype{};
11580 return get_number(input_format_t::msgpack, subtype) &&
11581 get_binary(input_format_t::msgpack, 16, result) &&
11582 assign_and_return_true(subtype);
11594 bool get_msgpack_array(
const std::size_t len)
11601 for (std::size_t i = 0; i < len; ++i)
11609 return sax->end_array();
11616 bool get_msgpack_object(
const std::size_t len)
11624 for (std::size_t i = 0; i < len; ++i)
11639 return sax->end_object();
11653 bool parse_ubjson_internal(
const bool get_char =
true)
11655 return get_ubjson_value(get_char ? get_ignore_noop() : current);
11672 bool get_ubjson_string(string_t& result,
const bool get_char =
true)
11688 std::uint8_t len{};
11689 return get_number(input_format, len) && get_string(input_format, len, result);
11695 return get_number(input_format, len) && get_string(input_format, len, result);
11700 std::int16_t len{};
11701 return get_number(input_format, len) && get_string(input_format, len, result);
11706 std::int32_t len{};
11707 return get_number(input_format, len) && get_string(input_format, len, result);
11712 std::int64_t len{};
11713 return get_number(input_format, len) && get_string(input_format, len, result);
11718 if (input_format != input_format_t::bjdata)
11722 std::uint16_t len{};
11723 return get_number(input_format, len) && get_string(input_format, len, result);
11728 if (input_format != input_format_t::bjdata)
11732 std::uint32_t len{};
11733 return get_number(input_format, len) && get_string(input_format, len, result);
11738 if (input_format != input_format_t::bjdata)
11742 std::uint64_t len{};
11743 return get_number(input_format, len) && get_string(input_format, len, result);
11749 auto last_token = get_token_string();
11750 std::string message;
11752 if (input_format != input_format_t::bjdata)
11754 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11758 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11760 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11767 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
11769 std::pair<std::size_t, char_int_type> size_and_type;
11771 bool no_ndarray =
true;
11778 if (size_and_type.first != npos)
11780 if (size_and_type.second != 0)
11782 if (size_and_type.second !=
'N')
11784 for (std::size_t i = 0; i < size_and_type.first; ++i)
11790 dim.push_back(dimlen);
11796 for (std::size_t i = 0; i < size_and_type.first; ++i)
11802 dim.push_back(dimlen);
11808 while (current !=
']')
11814 dim.push_back(dimlen);
11832 bool get_ubjson_size_value(std::size_t& result,
bool& is_ndarray, char_int_type prefix = 0)
11836 prefix = get_ignore_noop();
11843 std::uint8_t number{};
11848 result =
static_cast<std::size_t
>(number);
11854 std::int8_t number{};
11861 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11862 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11864 result =
static_cast<std::size_t
>(number);
11870 std::int16_t number{};
11877 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11878 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11880 result =
static_cast<std::size_t
>(number);
11886 std::int32_t number{};
11893 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11894 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11896 result =
static_cast<std::size_t
>(number);
11902 std::int64_t number{};
11909 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11910 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11912 if (!value_in_range_of<std::size_t>(number))
11914 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11915 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11917 result =
static_cast<std::size_t
>(number);
11923 if (input_format != input_format_t::bjdata)
11927 std::uint16_t number{};
11932 result =
static_cast<std::size_t
>(number);
11938 if (input_format != input_format_t::bjdata)
11942 std::uint32_t number{};
11947 result = conditional_static_cast<std::size_t>(number);
11953 if (input_format != input_format_t::bjdata)
11957 std::uint64_t number{};
11962 if (!value_in_range_of<std::size_t>(number))
11964 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11965 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11973 if (input_format != input_format_t::bjdata)
11979 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimensional vector is not allowed",
"size"),
nullptr));
11981 std::vector<size_t> dim;
11986 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11988 result = dim.at(dim.size() - 1);
12002 string_t
key =
"_ArraySize_";
12003 if (
JSON_HEDLEY_UNLIKELY(!sax->start_object(3) || !sax->key(key) || !sax->start_array(dim.size())))
12015 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format,
"excessive ndarray size caused overflow",
"size"),
nullptr));
12019 if (result == 0 || result == npos)
12021 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format,
"excessive ndarray size caused overflow",
"size"),
nullptr));
12029 return sax->end_array();
12038 auto last_token = get_token_string();
12039 std::string message;
12041 if (input_format != input_format_t::bjdata)
12043 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
12047 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
12049 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
12063 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result,
bool inside_ndarray =
false)
12065 result.first = npos;
12067 bool is_ndarray =
false;
12071 if (current ==
'$')
12073 result.second =
get();
12074 if (input_format == input_format_t::bjdata
12075 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
12077 auto last_token = get_token_string();
12078 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12079 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
12094 auto last_token = get_token_string();
12095 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12096 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
12099 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12100 if (input_format == input_format_t::bjdata && is_ndarray)
12102 if (inside_ndarray)
12104 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12105 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
12107 result.second |= (1 << 8);
12112 if (current ==
'#')
12114 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
12115 if (input_format == input_format_t::bjdata && is_ndarray)
12117 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
12118 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
12130 bool get_ubjson_value(
const char_int_type prefix)
12134 case char_traits<char_type>::eof():
12135 return unexpect_eof(input_format,
"value");
12138 return sax->boolean(
true);
12140 return sax->boolean(
false);
12143 return sax->null();
12147 if (input_format != input_format_t::bjdata)
12151 std::uint8_t number{};
12152 return get_number(input_format, number) && sax->number_unsigned(number);
12157 std::uint8_t number{};
12158 return get_number(input_format, number) && sax->number_unsigned(number);
12163 std::int8_t number{};
12164 return get_number(input_format, number) && sax->number_integer(number);
12169 std::int16_t number{};
12170 return get_number(input_format, number) && sax->number_integer(number);
12175 std::int32_t number{};
12176 return get_number(input_format, number) && sax->number_integer(number);
12181 std::int64_t number{};
12182 return get_number(input_format, number) && sax->number_integer(number);
12187 if (input_format != input_format_t::bjdata)
12191 std::uint16_t number{};
12192 return get_number(input_format, number) && sax->number_unsigned(number);
12197 if (input_format != input_format_t::bjdata)
12201 std::uint32_t number{};
12202 return get_number(input_format, number) && sax->number_unsigned(number);
12207 if (input_format != input_format_t::bjdata)
12211 std::uint64_t number{};
12212 return get_number(input_format, number) && sax->number_unsigned(number);
12217 if (input_format != input_format_t::bjdata)
12221 const auto byte1_raw =
get();
12226 const auto byte2_raw =
get();
12232 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
12233 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
12243 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
12244 const double val = [&half]
12246 const int exp = (half >> 10u) & 0x1Fu;
12247 const unsigned int mant = half & 0x3FFu;
12253 return std::ldexp(mant, -24);
12256 ? std::numeric_limits<double>::infinity()
12257 : std::numeric_limits<double>::quiet_NaN();
12259 return std::ldexp(mant + 1024, exp - 25);
12262 return sax->number_float((half & 0x8000u) != 0
12263 ?
static_cast<number_float_t
>(-val)
12264 :
static_cast<number_float_t
>(val),
"");
12270 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
12276 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
12281 return get_ubjson_high_precision_number();
12293 auto last_token = get_token_string();
12294 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
12295 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
12297 string_t s(1,
static_cast<typename string_t::value_type
>(current));
12298 return sax->string(s);
12304 return get_ubjson_string(s) && sax->string(s);
12308 return get_ubjson_array();
12311 return get_ubjson_object();
12316 auto last_token = get_token_string();
12317 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format,
"invalid byte: 0x" + last_token,
"value"),
nullptr));
12323 bool get_ubjson_array()
12325 std::pair<std::size_t, char_int_type> size_and_type;
12334 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12336 size_and_type.second &= ~(
static_cast<char_int_type
>(1) << 8);
12337 auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](
const bjd_type & p, char_int_type t)
12339 return p.first < t;
12341 string_t
key =
"_ArrayType_";
12344 auto last_token = get_token_string();
12345 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12346 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
12349 string_t type = it->second;
12355 if (size_and_type.second ==
'C' || size_and_type.second ==
'B')
12357 size_and_type.second =
'U';
12360 key =
"_ArrayData_";
12366 for (std::size_t i = 0; i < size_and_type.first; ++i)
12374 return (sax->end_array() && sax->end_object());
12378 if (input_format == input_format_t::bjdata && size_and_type.first != npos && size_and_type.second ==
'B')
12381 return get_binary(input_format, size_and_type.first, result) && sax->binary(result);
12384 if (size_and_type.first != npos)
12391 if (size_and_type.second != 0)
12393 if (size_and_type.second !=
'N')
12395 for (std::size_t i = 0; i < size_and_type.first; ++i)
12406 for (std::size_t i = 0; i < size_and_type.first; ++i)
12422 while (current !=
']')
12432 return sax->end_array();
12438 bool get_ubjson_object()
12440 std::pair<std::size_t, char_int_type> size_and_type;
12447 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
12449 auto last_token = get_token_string();
12450 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
12451 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
12455 if (size_and_type.first != npos)
12462 if (size_and_type.second != 0)
12464 for (std::size_t i = 0; i < size_and_type.first; ++i)
12479 for (std::size_t i = 0; i < size_and_type.first; ++i)
12500 while (current !=
'}')
12515 return sax->end_object();
12521 bool get_ubjson_high_precision_number()
12524 std::size_t size{};
12525 bool no_ndarray =
true;
12526 auto res = get_ubjson_size_value(size, no_ndarray);
12533 std::vector<char> number_vector;
12534 for (std::size_t i = 0; i < size; ++i)
12541 number_vector.push_back(
static_cast<char>(current));
12546 auto number_lexer = detail::lexer<BasicJsonType, ia_type>(
detail::input_adapter(number_vector),
false);
12547 const auto result_number = number_lexer.scan();
12548 const auto number_string = number_lexer.get_token_string();
12549 const auto result_remainder = number_lexer.scan();
12555 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12556 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12559 switch (result_number)
12561 case token_type::value_integer:
12562 return sax->number_integer(number_lexer.get_number_integer());
12563 case token_type::value_unsigned:
12564 return sax->number_unsigned(number_lexer.get_number_unsigned());
12565 case token_type::value_float:
12566 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
12567 case token_type::uninitialized:
12568 case token_type::literal_true:
12569 case token_type::literal_false:
12570 case token_type::literal_null:
12571 case token_type::value_string:
12572 case token_type::begin_array:
12573 case token_type::begin_object:
12574 case token_type::end_array:
12575 case token_type::end_object:
12576 case token_type::name_separator:
12577 case token_type::value_separator:
12578 case token_type::parse_error:
12579 case token_type::end_of_input:
12580 case token_type::literal_or_value:
12582 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
12583 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
12600 char_int_type
get()
12603 return current = ia.get_character();
12615 bool get_to(T& dest,
const input_format_t format,
const char* context)
12617 auto new_chars_read = ia.get_elements(&dest);
12618 chars_read += new_chars_read;
12623 sax->parse_error(chars_read,
"<end of file>", parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12632 char_int_type get_ignore_noop()
12638 while (current ==
'N');
12643 template<
class NumberType>
12644 static void byte_swap(NumberType& number)
12646 constexpr std::size_t sz =
sizeof(number);
12647#ifdef __cpp_lib_byteswap
12648 if constexpr (sz == 1)
12652 else if constexpr(std::is_integral_v<NumberType>)
12654 number = std::byteswap(number);
12660 auto* ptr =
reinterpret_cast<std::uint8_t*
>(&number);
12661 for (std::size_t i = 0; i < sz / 2; ++i)
12665#ifdef __cpp_lib_byteswap
12685 template<
typename NumberType,
bool InputIsLittleEndian = false>
12686 bool get_number(
const input_format_t format, NumberType& result)
12694 if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
12715 template<
typename NumberType>
12716 bool get_string(
const input_format_t format,
12717 const NumberType len,
12720 bool success =
true;
12721 for (NumberType i = 0; i < len; i++)
12729 result.push_back(
static_cast<typename string_t::value_type
>(current));
12748 template<
typename NumberType>
12749 bool get_binary(
const input_format_t format,
12750 const NumberType len,
12753 bool success =
true;
12754 for (NumberType i = 0; i < len; i++)
12762 result.push_back(
static_cast<std::uint8_t
>(current));
12773 bool unexpect_eof(const input_format_t format, const
char* context)
const
12777 return sax->parse_error(chars_read,
"<end of file>",
12778 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12786 std::string get_token_string()
const
12788 std::array<char, 3> cr{{}};
12789 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
12790 return std::string{cr.data()};
12799 std::string exception_message(
const input_format_t format,
12800 const std::string& detail,
12801 const std::string& context)
const
12803 std::string error_msg =
"syntax error while parsing ";
12807 case input_format_t::cbor:
12808 error_msg +=
"CBOR";
12811 case input_format_t::msgpack:
12812 error_msg +=
"MessagePack";
12815 case input_format_t::ubjson:
12816 error_msg +=
"UBJSON";
12819 case input_format_t::bson:
12820 error_msg +=
"BSON";
12823 case input_format_t::bjdata:
12824 error_msg +=
"BJData";
12827 case input_format_t::json:
12832 return concat(error_msg,
' ', context,
": ", detail);
12839 InputAdapterType ia;
12842 char_int_type current = char_traits<char_type>::eof();
12845 std::size_t chars_read = 0;
12854 json_sax_t* sax =
nullptr;
12857#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12858 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
12860#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
12861 make_array<bjd_type>( \
12862 bjd_type{'B', "byte"}, \
12863 bjd_type{'C', "char"}, \
12864 bjd_type{'D', "double"}, \
12865 bjd_type{'I', "int16"}, \
12866 bjd_type{'L', "int64"}, \
12867 bjd_type{'M', "uint64"}, \
12868 bjd_type{'U', "uint8"}, \
12869 bjd_type{'d', "single"}, \
12870 bjd_type{'i', "int8"}, \
12871 bjd_type{'l', "int32"}, \
12872 bjd_type{'m', "uint32"}, \
12873 bjd_type{'u', "uint16"})
12881 using bjd_type = std::pair<char_int_type, string_t>;
12886#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
12887#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
12890#ifndef JSON_HAS_CPP_17
12891 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12892 constexpr std::size_t binary_reader<BasicJsonType, InputAdapterType, SAX>::npos;
12915#include <functional>
12960template<
typename BasicJsonType>
12962 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
12969template<
typename BasicJsonType,
typename InputAdapterType>
12972 using number_integer_t =
typename BasicJsonType::number_integer_t;
12973 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
12974 using number_float_t =
typename BasicJsonType::number_float_t;
12975 using string_t =
typename BasicJsonType::string_t;
12983 const bool allow_exceptions_ =
true,
12984 const bool skip_comments =
false)
12985 : callback(
std::move(cb))
12986 , m_lexer(
std::move(adapter), skip_comments)
12987 , allow_exceptions(allow_exceptions_)
13008 sax_parse_internal(&sdp);
13011 if (
strict && (get_token() != token_type::end_of_input))
13014 m_lexer.get_token_string(),
13016 exception_message(token_type::end_of_input,
"value"),
nullptr));
13028 if (result.is_discarded())
13036 sax_parse_internal(&sdp);
13039 if (
strict && (get_token() != token_type::end_of_input))
13042 m_lexer.get_token_string(),
13043 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13054 result.assert_invariant();
13069 template<
typename SAX>
13074 const bool result = sax_parse_internal(sax);
13077 if (result &&
strict && (get_token() != token_type::end_of_input))
13079 return sax->parse_error(m_lexer.get_position(),
13080 m_lexer.get_token_string(),
13081 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
13088 template<
typename SAX>
13090 bool sax_parse_internal(SAX* sax)
13094 std::vector<bool> states;
13096 bool skip_to_state_evaluation =
false;
13100 if (!skip_to_state_evaluation)
13103 switch (last_token)
13105 case token_type::begin_object:
13113 if (get_token() == token_type::end_object)
13125 return sax->parse_error(m_lexer.get_position(),
13126 m_lexer.get_token_string(),
13127 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13137 return sax->parse_error(m_lexer.get_position(),
13138 m_lexer.get_token_string(),
13139 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13143 states.push_back(
false);
13150 case token_type::begin_array:
13158 if (get_token() == token_type::end_array)
13168 states.push_back(
true);
13174 case token_type::value_float:
13176 const auto res = m_lexer.get_number_float();
13180 return sax->parse_error(m_lexer.get_position(),
13181 m_lexer.get_token_string(),
13182 out_of_range::create(406,
concat(
"number overflow parsing '", m_lexer.get_token_string(),
'\''),
nullptr));
13193 case token_type::literal_false:
13202 case token_type::literal_null:
13211 case token_type::literal_true:
13220 case token_type::value_integer:
13229 case token_type::value_string:
13238 case token_type::value_unsigned:
13247 case token_type::parse_error:
13250 return sax->parse_error(m_lexer.get_position(),
13251 m_lexer.get_token_string(),
13252 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
13254 case token_type::end_of_input:
13258 return sax->parse_error(m_lexer.get_position(),
13259 m_lexer.get_token_string(),
13260 parse_error::create(101, m_lexer.get_position(),
13261 "attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
13264 return sax->parse_error(m_lexer.get_position(),
13265 m_lexer.get_token_string(),
13266 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13268 case token_type::uninitialized:
13269 case token_type::end_array:
13270 case token_type::end_object:
13271 case token_type::name_separator:
13272 case token_type::value_separator:
13273 case token_type::literal_or_value:
13276 return sax->parse_error(m_lexer.get_position(),
13277 m_lexer.get_token_string(),
13278 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
13284 skip_to_state_evaluation =
false;
13288 if (states.empty())
13297 if (get_token() == token_type::value_separator)
13318 skip_to_state_evaluation =
true;
13322 return sax->parse_error(m_lexer.get_position(),
13323 m_lexer.get_token_string(),
13324 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
13330 if (get_token() == token_type::value_separator)
13335 return sax->parse_error(m_lexer.get_position(),
13336 m_lexer.get_token_string(),
13337 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
13348 return sax->parse_error(m_lexer.get_position(),
13349 m_lexer.get_token_string(),
13350 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
13372 skip_to_state_evaluation =
true;
13376 return sax->parse_error(m_lexer.get_position(),
13377 m_lexer.get_token_string(),
13378 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
13383 token_type get_token()
13385 return last_token = m_lexer.scan();
13388 std::string exception_message(
const token_type expected,
const std::string& context)
13390 std::string error_msg =
"syntax error ";
13392 if (!context.empty())
13394 error_msg +=
concat(
"while parsing ", context,
' ');
13399 if (last_token == token_type::parse_error)
13401 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
13402 m_lexer.get_token_string(),
'\'');
13406 error_msg +=
concat(
"unexpected ", lexer_t::token_type_name(last_token));
13409 if (expected != token_type::uninitialized)
13411 error_msg +=
concat(
"; expected ", lexer_t::token_type_name(expected));
13419 const parser_callback_t<BasicJsonType> callback =
nullptr;
13421 token_type last_token = token_type::uninitialized;
13425 const bool allow_exceptions =
true;
13477 using difference_type = std::ptrdiff_t;
13478 static constexpr difference_type begin_value = 0;
13479 static constexpr difference_type end_value = begin_value + 1;
13483 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
13494 m_it = begin_value;
13506 return m_it == begin_value;
13512 return m_it == end_value;
13517 return lhs.m_it == rhs.m_it;
13522 return lhs.m_it < rhs.m_it;
13527 auto result = *
this;
13534 return lhs.m_it - rhs.m_it;
13545 auto result = *
this;
13558 auto result = *
this;
13615#include <type_traits>
13637template<
typename IteratorType>
class iteration_proxy;
13638template<
typename IteratorType>
class iteration_proxy_value;
13656template<
typename BasicJsonType>
13662 friend other_iter_impl;
13663 friend BasicJsonType;
13667 using object_t =
typename BasicJsonType::object_t;
13668 using array_t =
typename BasicJsonType::array_t;
13671 "iter_impl only accepts (const) basic_json");
13673 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
13674 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>
::value,
13675 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
13690 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
13691 typename BasicJsonType::const_pointer,
13692 typename BasicJsonType::pointer>::type;
13695 typename std::conditional<std::is_const<BasicJsonType>::value,
13696 typename BasicJsonType::const_reference,
13697 typename BasicJsonType::reference>::type;
13714 switch (m_object->m_data.m_type)
13718 m_it.object_iterator =
typename object_t::iterator();
13724 m_it.array_iterator =
typename array_t::iterator();
13761 : m_object(other.m_object),
m_it(other.m_it)
13772 if (&other !=
this)
13774 m_object = other.m_object;
13786 : m_object(other.m_object),
m_it(other.m_it)
13797 m_object = other.m_object;
13807 void set_begin() noexcept
13811 switch (m_object->m_data.m_type)
13815 m_it.object_iterator = m_object->m_data.m_value.object->begin();
13821 m_it.array_iterator = m_object->m_data.m_value.array->begin();
13828 m_it.primitive_iterator.set_end();
13841 m_it.primitive_iterator.set_begin();
13855 switch (m_object->m_data.m_type)
13859 m_it.object_iterator = m_object->m_data.m_value.object->end();
13865 m_it.array_iterator = m_object->m_data.m_value.array->end();
13879 m_it.primitive_iterator.set_end();
13894 switch (m_object->m_data.m_type)
13898 JSON_ASSERT(
m_it.object_iterator != m_object->m_data.m_value.object->end());
13899 return m_it.object_iterator->second;
13904 JSON_ASSERT(
m_it.array_iterator != m_object->m_data.m_value.array->end());
13905 return *
m_it.array_iterator;
13938 switch (m_object->m_data.m_type)
13942 JSON_ASSERT(
m_it.object_iterator != m_object->m_data.m_value.object->end());
13943 return &(
m_it.object_iterator->second);
13948 JSON_ASSERT(
m_it.array_iterator != m_object->m_data.m_value.array->end());
13949 return &*
m_it.array_iterator;
13978 auto result = *
this;
13991 switch (m_object->m_data.m_type)
13995 std::advance(
m_it.object_iterator, 1);
14001 std::advance(
m_it.array_iterator, 1);
14015 ++
m_it.primitive_iterator;
14029 auto result = *
this;
14042 switch (m_object->m_data.m_type)
14046 std::advance(
m_it.object_iterator, -1);
14052 std::advance(
m_it.array_iterator, -1);
14066 --
m_it.primitive_iterator;
14078 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
14088 if (m_object ==
nullptr)
14093 switch (m_object->m_data.m_type)
14096 return (
m_it.object_iterator == other.m_it.object_iterator);
14099 return (
m_it.array_iterator == other.m_it.array_iterator);
14110 return (
m_it.primitive_iterator == other.m_it.primitive_iterator);
14118 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
14137 if (m_object ==
nullptr)
14143 switch (m_object->m_data.m_type)
14149 return (
m_it.array_iterator < other.
m_it.array_iterator);
14160 return (
m_it.primitive_iterator < other.
m_it.primitive_iterator);
14170 return !other.operator < (*this);
14199 switch (m_object->m_data.m_type)
14206 std::advance(
m_it.array_iterator, i);
14220 m_it.primitive_iterator += i;
14243 auto result = *
this;
14265 auto result = *
this;
14278 switch (m_object->m_data.m_type)
14284 return m_it.array_iterator - other.
m_it.array_iterator;
14295 return m_it.primitive_iterator - other.
m_it.primitive_iterator;
14307 switch (m_object->m_data.m_type)
14313 return *std::next(
m_it.array_iterator, n);
14341 const typename object_t::key_type&
key()
const
14347 return m_it.object_iterator->first;
14418template<
typename Base>
14492 auto it = --this->base();
14499 auto it = --this->base();
14500 return it.operator * ();
14520#include <type_traits>
14543 std::is_same<T, void>::value,
14562#include <algorithm>
14590template<
typename RefStringType>
14600 template<
typename T>
14601 struct string_t_helper
14609 using type = StringType;
14614 using string_t =
typename string_t_helper<RefStringType>::type;
14619 : reference_tokens(split(s))
14626 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
14630 return detail::concat(a,
'/', detail::escape(b));
14656 reference_tokens.insert(reference_tokens.end(),
14657 ptr.reference_tokens.begin(),
14658 ptr.reference_tokens.end());
14674 return *
this /= std::to_string(array_idx);
14722 reference_tokens.pop_back();
14734 return reference_tokens.back();
14741 reference_tokens.push_back(token);
14748 reference_tokens.push_back(std::move(token));
14755 return reference_tokens.empty();
14769 template<
typename BasicJsonType>
14770 static typename BasicJsonType::size_type array_index(
const string_t& s)
14772 using size_type =
typename BasicJsonType::size_type;
14786 const char* p = s.c_str();
14787 char* p_end =
nullptr;
14789 const unsigned long long res = std::strtoull(p, &p_end, 10);
14799 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
14804 return static_cast<size_type
>(res);
14808 json_pointer top()
const
14815 json_pointer result = *
this;
14816 result.reference_tokens = {reference_tokens[0]};
14829 template<
typename BasicJsonType>
14830 BasicJsonType& get_and_create(BasicJsonType& j)
const
14836 for (
const auto& reference_token : reference_tokens)
14838 switch (result->type())
14842 if (reference_token ==
"0")
14845 result = &result->operator[](0);
14850 result = &result->operator[](reference_token);
14858 result = &result->operator[](reference_token);
14865 result = &result->operator[](array_index<BasicJsonType>(reference_token));
14909 template<
typename BasicJsonType>
14910 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
14912 for (
const auto& reference_token : reference_tokens)
14915 if (ptr->is_null())
14919 std::all_of(reference_token.begin(), reference_token.end(),
14920 [](
const unsigned char x)
14922 return std::isdigit(x);
14926 *ptr = (nums || reference_token ==
"-")
14931 switch (ptr->type())
14936 ptr = &ptr->operator[](reference_token);
14942 if (reference_token ==
"-")
14945 ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
14950 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14977 template<
typename BasicJsonType>
14978 BasicJsonType& get_checked(BasicJsonType* ptr)
const
14980 for (
const auto& reference_token : reference_tokens)
14982 switch (ptr->type())
14987 ptr = &ptr->at(reference_token);
14997 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
14998 ") is out of range"), ptr));
15002 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
15035 template<
typename BasicJsonType>
15036 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
15038 for (
const auto& reference_token : reference_tokens)
15040 switch (ptr->type())
15045 ptr = &ptr->operator[](reference_token);
15058 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
15084 template<
typename BasicJsonType>
15085 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
15087 for (
const auto& reference_token : reference_tokens)
15089 switch (ptr->type())
15094 ptr = &ptr->at(reference_token);
15104 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
15105 ") is out of range"), ptr));
15109 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
15133 template<
typename BasicJsonType>
15134 bool contains(
const BasicJsonType* ptr)
const
15136 for (
const auto& reference_token : reference_tokens)
15138 switch (ptr->type())
15142 if (!ptr->contains(reference_token))
15148 ptr = &ptr->operator[](reference_token);
15159 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
15171 for (std::size_t i = 1; i < reference_token.size(); i++)
15181 const auto idx = array_index<BasicJsonType>(reference_token);
15182 if (idx >= ptr->size())
15188 ptr = &ptr->operator[](idx);
15222 static std::vector<string_t> split(
const string_t& reference_string)
15224 std::vector<string_t> result;
15227 if (reference_string.empty())
15243 std::size_t slash = reference_string.find_first_of(
'/', 1),
15250 start = (slash == string_t::npos) ? 0 : slash + 1,
15252 slash = reference_string.find_first_of(
'/', start))
15256 auto reference_token = reference_string.substr(start, slash - start);
15259 for (std::size_t pos = reference_token.find_first_of(
'~');
15260 pos != string_t::npos;
15261 pos = reference_token.find_first_of(
'~', pos + 1))
15267 (reference_token[pos + 1] !=
'0' &&
15268 reference_token[pos + 1] !=
'1')))
15276 result.push_back(reference_token);
15290 template<
typename BasicJsonType>
15291 static void flatten(
const string_t& reference_string,
15292 const BasicJsonType& value,
15293 BasicJsonType& result)
15295 switch (
value.type())
15299 if (
value.m_data.m_value.array->empty())
15302 result[reference_string] =
nullptr;
15307 for (std::size_t i = 0; i <
value.m_data.m_value.array->size(); ++i)
15310 value.m_data.m_value.array->operator[](i), result);
15318 if (
value.m_data.m_value.object->empty())
15321 result[reference_string] =
nullptr;
15326 for (
const auto& element : *
value.m_data.m_value.object)
15345 result[reference_string] =
value;
15361 template<
typename BasicJsonType>
15362 static BasicJsonType
15363 unflatten(
const BasicJsonType& value)
15370 BasicJsonType result;
15373 for (
const auto& element : *
value.m_data.m_value.object)
15384 json_pointer(element.first).get_and_create(result) = element.second;
15391 json_pointer<string_t> convert() const&
15393 json_pointer<string_t> result;
15394 result.reference_tokens = reference_tokens;
15398 json_pointer<string_t> convert()&&
15400 json_pointer<string_t> result;
15401 result.reference_tokens = std::move(reference_tokens);
15406#if JSON_HAS_THREE_WAY_COMPARISON
15409 template<
typename RefStringTypeRhs>
15410 bool operator==(
const json_pointer<RefStringTypeRhs>& rhs)
const noexcept
15412 return reference_tokens == rhs.reference_tokens;
15420 return *
this == json_pointer(rhs);
15424 template<
typename RefStringTypeRhs>
15425 std::strong_ordering operator<=>(
const json_pointer<RefStringTypeRhs>& rhs)
const noexcept
15427 return reference_tokens <=> rhs.reference_tokens;
15432 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15434 friend bool operator==(
const json_pointer<RefStringTypeLhs>& lhs,
15435 const json_pointer<RefStringTypeRhs>& rhs)
noexcept;
15439 template<
typename RefStringTypeLhs,
typename StringType>
15441 friend bool operator==(
const json_pointer<RefStringTypeLhs>& lhs,
15442 const StringType& rhs);
15446 template<
typename RefStringTypeRhs,
typename StringType>
15448 friend bool operator==(
const StringType& lhs,
15449 const json_pointer<RefStringTypeRhs>& rhs);
15453 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15455 friend bool operator!=(
const json_pointer<RefStringTypeLhs>& lhs,
15456 const json_pointer<RefStringTypeRhs>& rhs)
noexcept;
15460 template<
typename RefStringTypeLhs,
typename StringType>
15462 friend bool operator!=(
const json_pointer<RefStringTypeLhs>& lhs,
15463 const StringType& rhs);
15467 template<
typename RefStringTypeRhs,
typename StringType>
15469 friend bool operator!=(
const StringType& lhs,
15470 const json_pointer<RefStringTypeRhs>& rhs);
15473 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15475 friend bool operator<(
const json_pointer<RefStringTypeLhs>& lhs,
15476 const json_pointer<RefStringTypeRhs>& rhs)
noexcept;
15481 std::vector<string_t> reference_tokens;
15484#if !JSON_HAS_THREE_WAY_COMPARISON
15486template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15490 return lhs.reference_tokens == rhs.reference_tokens;
15493template<
typename RefStringTypeLhs,
15497 const StringType& rhs)
15502template<
typename RefStringTypeRhs,
15505inline
bool operator==(const StringType& lhs,
15511template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15515 return !(lhs == rhs);
15518template<
typename RefStringTypeLhs,
15522 const StringType& rhs)
15524 return !(lhs == rhs);
15527template<
typename RefStringTypeRhs,
15530inline
bool operator!=(const StringType& lhs,
15533 return !(lhs == rhs);
15536template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
15540 return lhs.reference_tokens < rhs.reference_tokens;
15557#include <initializer_list>
15569template<
typename BasicJsonType>
15580 : value_ref(&
value)
15584 : owned_value(init)
15591 : owned_value(
std::forward<Args>(args)...)
15603 if (value_ref ==
nullptr)
15605 return std::move(owned_value);
15612 return value_ref ? *value_ref : owned_value;
15621 mutable value_type owned_value =
nullptr;
15622 value_type
const* value_ref =
nullptr;
15651#include <algorithm>
15677#include <algorithm>
15711template<typename CharType>
15715template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
15731 v.insert(v.end(), s, s + length);
15735 std::vector<CharType, AllocatorType>& v;
15740template<
typename CharType>
15756 stream.write(s,
static_cast<std::streamsize
>(length));
15760 std::basic_ostream<CharType>& stream;
15765template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15781 str.append(s, length);
15788template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15792 template<
typename AllocatorType = std::allocator<CharType>>
15837template<
typename BasicJsonType,
typename CharType>
15840 using string_t =
typename BasicJsonType::string_t;
15841 using binary_t =
typename BasicJsonType::binary_t;
15842 using number_float_t =
typename BasicJsonType::number_float_t;
15865 write_bson_object(*j.m_data.m_value.object);
15900 oa->write_character(j.m_data.m_value.boolean
15908 if (j.m_data.m_value.number_integer >= 0)
15913 if (j.m_data.m_value.number_integer <= 0x17)
15915 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15917 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15920 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15922 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15925 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15927 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15930 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15935 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15942 const auto positive_number = -1 - j.m_data.m_value.number_integer;
15943 if (j.m_data.m_value.number_integer >= -24)
15945 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
15947 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15950 write_number(
static_cast<std::uint8_t
>(positive_number));
15952 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15955 write_number(
static_cast<std::uint16_t
>(positive_number));
15957 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15960 write_number(
static_cast<std::uint32_t
>(positive_number));
15965 write_number(
static_cast<std::uint64_t
>(positive_number));
15973 if (j.m_data.m_value.number_unsigned <= 0x17)
15975 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15977 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15980 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15982 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15985 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_unsigned));
15987 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15990 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_unsigned));
15995 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned));
16002 if (std::isnan(j.m_data.m_value.number_float))
16009 else if (std::isinf(j.m_data.m_value.number_float))
16026 const auto N = j.m_data.m_value.string->size();
16029 write_number(
static_cast<std::uint8_t
>(0x60 + N));
16031 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16034 write_number(
static_cast<std::uint8_t
>(N));
16036 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16039 write_number(
static_cast<std::uint16_t
>(N));
16041 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16044 write_number(
static_cast<std::uint32_t
>(N));
16047 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16050 write_number(
static_cast<std::uint64_t
>(N));
16055 oa->write_characters(
16056 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16057 j.m_data.m_value.string->size());
16064 const auto N = j.m_data.m_value.array->size();
16067 write_number(
static_cast<std::uint8_t
>(0x80 + N));
16069 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16072 write_number(
static_cast<std::uint8_t
>(N));
16074 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16077 write_number(
static_cast<std::uint16_t
>(N));
16079 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16082 write_number(
static_cast<std::uint32_t
>(N));
16085 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16088 write_number(
static_cast<std::uint64_t
>(N));
16093 for (
const auto& el : *j.m_data.m_value.array)
16102 if (j.m_data.m_value.binary->has_subtype())
16104 if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
16106 write_number(
static_cast<std::uint8_t
>(0xd8));
16107 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.binary->subtype()));
16109 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
16111 write_number(
static_cast<std::uint8_t
>(0xd9));
16112 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.binary->subtype()));
16114 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
16116 write_number(
static_cast<std::uint8_t
>(0xda));
16117 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.binary->subtype()));
16119 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
16121 write_number(
static_cast<std::uint8_t
>(0xdb));
16122 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.binary->subtype()));
16127 const auto N = j.m_data.m_value.binary->size();
16130 write_number(
static_cast<std::uint8_t
>(0x40 + N));
16132 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16135 write_number(
static_cast<std::uint8_t
>(N));
16137 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16140 write_number(
static_cast<std::uint16_t
>(N));
16142 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16145 write_number(
static_cast<std::uint32_t
>(N));
16148 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16151 write_number(
static_cast<std::uint64_t
>(N));
16156 oa->write_characters(
16157 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16166 const auto N = j.m_data.m_value.object->size();
16169 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
16171 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16174 write_number(
static_cast<std::uint8_t
>(N));
16176 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16179 write_number(
static_cast<std::uint16_t
>(N));
16181 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16184 write_number(
static_cast<std::uint32_t
>(N));
16187 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
16190 write_number(
static_cast<std::uint64_t
>(N));
16195 for (
const auto& el : *j.m_data.m_value.object)
16224 oa->write_character(j.m_data.m_value.boolean
16232 if (j.m_data.m_value.number_integer >= 0)
16237 if (j.m_data.m_value.number_unsigned < 128)
16240 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16242 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16246 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16248 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16252 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
16254 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16258 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
16260 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16264 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
16269 if (j.m_data.m_value.number_integer >= -32)
16272 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
16274 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
16275 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16279 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
16281 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
16282 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16286 write_number(
static_cast<std::int16_t
>(j.m_data.m_value.number_integer));
16288 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
16289 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16293 write_number(
static_cast<std::int32_t
>(j.m_data.m_value.number_integer));
16295 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
16296 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16300 write_number(
static_cast<std::int64_t
>(j.m_data.m_value.number_integer));
16308 if (j.m_data.m_value.number_unsigned < 128)
16311 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16313 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
16317 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
16319 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
16323 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
16325 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
16329 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
16331 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16335 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
16349 const auto N = j.m_data.m_value.string->size();
16353 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
16355 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
16359 write_number(
static_cast<std::uint8_t
>(N));
16361 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16365 write_number(
static_cast<std::uint16_t
>(N));
16367 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16371 write_number(
static_cast<std::uint32_t
>(N));
16375 oa->write_characters(
16376 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16377 j.m_data.m_value.string->size());
16384 const auto N = j.m_data.m_value.array->size();
16388 write_number(
static_cast<std::uint8_t
>(0x90 | N));
16390 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16394 write_number(
static_cast<std::uint16_t
>(N));
16396 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16400 write_number(
static_cast<std::uint32_t
>(N));
16404 for (
const auto& el : *j.m_data.m_value.array)
16415 const bool use_ext = j.m_data.m_value.binary->has_subtype();
16418 const auto N = j.m_data.m_value.binary->size();
16419 if (N <= (std::numeric_limits<std::uint8_t>::max)())
16421 std::uint8_t output_type{};
16428 output_type = 0xD4;
16431 output_type = 0xD5;
16434 output_type = 0xD6;
16437 output_type = 0xD7;
16440 output_type = 0xD8;
16443 output_type = 0xC7;
16451 output_type = 0xC4;
16458 write_number(
static_cast<std::uint8_t
>(N));
16461 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16463 const std::uint8_t output_type = use_ext
16468 write_number(
static_cast<std::uint16_t
>(N));
16470 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16472 const std::uint8_t output_type = use_ext
16477 write_number(
static_cast<std::uint32_t
>(N));
16483 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.binary->subtype()));
16487 oa->write_characters(
16488 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16497 const auto N = j.m_data.m_value.object->size();
16501 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
16503 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
16507 write_number(
static_cast<std::uint16_t
>(N));
16509 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
16513 write_number(
static_cast<std::uint32_t
>(N));
16517 for (
const auto& el : *j.m_data.m_value.object)
16540 const bool use_type,
const bool add_prefix =
true,
16560 oa->write_character(j.m_data.m_value.boolean
16569 write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata);
16575 write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
16581 write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata);
16591 write_number_with_ubjson_prefix(j.m_data.m_value.string->size(),
true, use_bjdata);
16592 oa->write_characters(
16593 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
16594 j.m_data.m_value.string->size());
16605 bool prefix_required =
true;
16606 if (use_type && !j.m_data.m_value.array->empty())
16609 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16610 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
16611 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
16613 return ubjson_prefix(v, use_bjdata) == first_prefix;
16616 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16618 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16620 prefix_required =
false;
16622 oa->write_character(first_prefix);
16629 write_number_with_ubjson_prefix(j.m_data.m_value.array->size(),
true, use_bjdata);
16632 for (
const auto& el : *j.m_data.m_value.array)
16634 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16652 if (use_type && (bjdata_draft3 || !j.m_data.m_value.binary->empty()))
16656 oa->write_character(bjdata_draft3 ?
'B' :
'U');
16662 write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(),
true, use_bjdata);
16667 oa->write_characters(
16668 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
16669 j.m_data.m_value.binary->size());
16673 for (
size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
16675 oa->write_character(
to_char_type(bjdata_draft3 ?
'B' :
'U'));
16676 oa->write_character(j.m_data.m_value.binary->data()[i]);
16690 if (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find(
"_ArrayType_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArraySize_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArrayData_") != j.m_data.m_value.object->end())
16692 if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type, bjdata_version))
16703 bool prefix_required =
true;
16704 if (use_type && !j.m_data.m_value.object->empty())
16707 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
16708 const bool same_prefix = std::all_of(j.begin(), j.end(),
16709 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
16711 return ubjson_prefix(v, use_bjdata) == first_prefix;
16714 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
16716 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
16718 prefix_required =
false;
16720 oa->write_character(first_prefix);
16727 write_number_with_ubjson_prefix(j.m_data.m_value.object->size(),
true, use_bjdata);
16730 for (
const auto& el : *j.m_data.m_value.object)
16732 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
16733 oa->write_characters(
16734 reinterpret_cast<const CharType*
>(el.first.c_str()),
16736 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata, bjdata_version);
16762 static std::size_t calc_bson_entry_header_size(
const string_t& name,
const BasicJsonType& j)
16764 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
16770 static_cast<void>(j);
16771 return 1ul + name.size() + 1u;
16777 void write_bson_entry_header(
const string_t& name,
16778 const std::uint8_t element_type)
16780 oa->write_character(to_char_type(element_type));
16781 oa->write_characters(
16782 reinterpret_cast<const CharType*
>(name.c_str()),
16789 void write_bson_boolean(
const string_t& name,
16792 write_bson_entry_header(name, 0x08);
16793 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
16799 void write_bson_double(
const string_t& name,
16800 const double value)
16802 write_bson_entry_header(name, 0x01);
16803 write_number<double>(value,
true);
16809 static std::size_t calc_bson_string_size(
const string_t& value)
16811 return sizeof(std::int32_t) +
value.size() + 1ul;
16817 void write_bson_string(
const string_t& name,
16820 write_bson_entry_header(name, 0x02);
16822 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
16823 oa->write_characters(
16824 reinterpret_cast<const CharType*
>(
value.c_str()),
16831 void write_bson_null(
const string_t& name)
16833 write_bson_entry_header(name, 0x0A);
16839 static std::size_t calc_bson_integer_size(
const std::int64_t value)
16841 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
16842 ?
sizeof(std::int32_t)
16843 :
sizeof(std::int64_t);
16849 void write_bson_integer(
const string_t& name,
16850 const std::int64_t value)
16852 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
16854 write_bson_entry_header(name, 0x10);
16855 write_number<std::int32_t>(
static_cast<std::int32_t
>(value),
true);
16859 write_bson_entry_header(name, 0x12);
16860 write_number<std::int64_t>(
static_cast<std::int64_t
>(value),
true);
16867 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t value)
noexcept
16869 return (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16870 ?
sizeof(std::int32_t)
16871 : sizeof(std::int64_t);
16877 void write_bson_unsigned(
const string_t& name,
16878 const BasicJsonType& j)
16880 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16882 write_bson_entry_header(name, 0x10 );
16883 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_data.m_value.number_unsigned),
true);
16885 else if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16887 write_bson_entry_header(name, 0x12 );
16888 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_data.m_value.number_unsigned),
true);
16892 write_bson_entry_header(name, 0x11 );
16893 write_number<std::uint64_t>(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned),
true);
16900 void write_bson_object_entry(
const string_t& name,
16901 const typename BasicJsonType::object_t& value)
16903 write_bson_entry_header(name, 0x03);
16904 write_bson_object(value);
16910 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t& value)
16912 std::size_t array_index = 0ul;
16914 const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value),
static_cast<std::size_t
>(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
16916 return result + calc_bson_element_size(std::to_string(array_index++), el);
16919 return sizeof(std::int32_t) + embedded_document_size + 1ul;
16925 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t& value)
16927 return sizeof(std::int32_t) +
value.size() + 1ul;
16933 void write_bson_array(
const string_t& name,
16934 const typename BasicJsonType::array_t& value)
16936 write_bson_entry_header(name, 0x04);
16937 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(value)),
true);
16939 std::size_t array_index = 0ul;
16941 for (
const auto& el : value)
16943 write_bson_element(std::to_string(array_index++), el);
16946 oa->write_character(to_char_type(0x00));
16952 void write_bson_binary(
const string_t& name,
16955 write_bson_entry_header(name, 0x05);
16957 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
16958 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
16960 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
16967 static std::size_t calc_bson_element_size(
const string_t& name,
16968 const BasicJsonType& j)
16970 const auto header_size = calc_bson_entry_header_size(name, j);
16973 case value_t::object:
16974 return header_size + calc_bson_object_size(*j.m_data.m_value.object);
16976 case value_t::array:
16977 return header_size + calc_bson_array_size(*j.m_data.m_value.array);
16979 case value_t::binary:
16980 return header_size + calc_bson_binary_size(*j.m_data.m_value.binary);
16982 case value_t::boolean:
16983 return header_size + 1ul;
16985 case value_t::number_float:
16986 return header_size + 8ul;
16988 case value_t::number_integer:
16989 return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer);
16991 case value_t::number_unsigned:
16992 return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned);
16994 case value_t::string:
16995 return header_size + calc_bson_string_size(*j.m_data.m_value.string);
16997 case value_t::null:
16998 return header_size + 0ul;
17001 case value_t::discarded:
17015 void write_bson_element(
const string_t& name,
17016 const BasicJsonType& j)
17020 case value_t::object:
17021 return write_bson_object_entry(name, *j.m_data.m_value.object);
17023 case value_t::array:
17024 return write_bson_array(name, *j.m_data.m_value.array);
17026 case value_t::binary:
17027 return write_bson_binary(name, *j.m_data.m_value.binary);
17029 case value_t::boolean:
17030 return write_bson_boolean(name, j.m_data.m_value.boolean);
17032 case value_t::number_float:
17033 return write_bson_double(name, j.m_data.m_value.number_float);
17035 case value_t::number_integer:
17036 return write_bson_integer(name, j.m_data.m_value.number_integer);
17038 case value_t::number_unsigned:
17039 return write_bson_unsigned(name, j);
17041 case value_t::string:
17042 return write_bson_string(name, *j.m_data.m_value.string);
17044 case value_t::null:
17045 return write_bson_null(name);
17048 case value_t::discarded:
17062 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t& value)
17064 const std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
17065 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
17067 return result += calc_bson_element_size(el.first, el.second);
17070 return sizeof(std::int32_t) + document_size + 1ul;
17077 void write_bson_object(
const typename BasicJsonType::object_t& value)
17079 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(value)),
true);
17081 for (
const auto& el : value)
17083 write_bson_element(el.first, el.second);
17086 oa->write_character(to_char_type(0x00));
17093 static constexpr CharType get_cbor_float_prefix(
float )
17095 return to_char_type(0xFA);
17098 static constexpr CharType get_cbor_float_prefix(
double )
17100 return to_char_type(0xFB);
17107 static constexpr CharType get_msgpack_float_prefix(
float )
17109 return to_char_type(0xCA);
17112 static constexpr CharType get_msgpack_float_prefix(
double )
17114 return to_char_type(0xCB);
17122 template<
typename NumberType,
typename std::enable_if<
17123 std::is_floating_point<NumberType>::value,
int>::type = 0>
17124 void write_number_with_ubjson_prefix(
const NumberType n,
17125 const bool add_prefix,
17126 const bool use_bjdata)
17130 oa->write_character(get_ubjson_float_prefix(n));
17132 write_number(n, use_bjdata);
17136 template<
typename NumberType,
typename std::enable_if<
17137 std::is_unsigned<NumberType>::value,
int>::type = 0>
17138 void write_number_with_ubjson_prefix(
const NumberType n,
17139 const bool add_prefix,
17140 const bool use_bjdata)
17142 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
17146 oa->write_character(to_char_type(
'i'));
17148 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17150 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
17154 oa->write_character(to_char_type(
'U'));
17156 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17158 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
17162 oa->write_character(to_char_type(
'I'));
17164 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
17166 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
17170 oa->write_character(to_char_type(
'u'));
17172 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
17174 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17178 oa->write_character(to_char_type(
'l'));
17180 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
17182 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
17186 oa->write_character(to_char_type(
'm'));
17188 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
17190 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
17194 oa->write_character(to_char_type(
'L'));
17196 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
17198 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
17202 oa->write_character(to_char_type(
'M'));
17204 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
17210 oa->write_character(to_char_type(
'H'));
17213 const auto number = BasicJsonType(n).dump();
17214 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17215 for (std::size_t i = 0; i < number.size(); ++i)
17217 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
17223 template <
typename NumberType,
typename std::enable_if <
17224 std::is_signed<NumberType>::value&&
17225 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
17226 void write_number_with_ubjson_prefix(
const NumberType n,
17227 const bool add_prefix,
17228 const bool use_bjdata)
17230 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
17234 oa->write_character(to_char_type(
'i'));
17236 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
17238 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
17242 oa->write_character(to_char_type(
'U'));
17244 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
17246 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
17250 oa->write_character(to_char_type(
'I'));
17252 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
17254 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::max)())))
17258 oa->write_character(to_char_type(
'u'));
17260 write_number(
static_cast<uint16_t
>(n), use_bjdata);
17262 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
17266 oa->write_character(to_char_type(
'l'));
17268 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
17270 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::max)())))
17274 oa->write_character(to_char_type(
'm'));
17276 write_number(
static_cast<uint32_t
>(n), use_bjdata);
17278 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
17282 oa->write_character(to_char_type(
'L'));
17284 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
17291 oa->write_character(to_char_type(
'H'));
17294 const auto number = BasicJsonType(n).dump();
17295 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
17296 for (std::size_t i = 0; i < number.size(); ++i)
17298 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
17307 CharType ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
17311 case value_t::null:
17314 case value_t::boolean:
17315 return j.m_data.m_value.boolean ?
'T' :
'F';
17317 case value_t::number_integer:
17319 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
17323 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
17327 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
17331 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
17335 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
17339 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
17343 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
17351 case value_t::number_unsigned:
17353 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
17357 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
17361 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
17365 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
17369 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
17373 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
17377 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
17381 if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
17389 case value_t::number_float:
17390 return get_ubjson_float_prefix(j.m_data.m_value.number_float);
17392 case value_t::string:
17395 case value_t::array:
17396 case value_t::binary:
17399 case value_t::object:
17402 case value_t::discarded:
17408 static constexpr CharType get_ubjson_float_prefix(
float )
17413 static constexpr CharType get_ubjson_float_prefix(
double )
17421 bool write_bjdata_ndarray(
const typename BasicJsonType::object_t& value,
const bool use_count,
const bool use_type,
const bjdata_version_t bjdata_version)
17423 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
17424 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'},
17425 {
"char",
'C'}, {
"byte",
'B'}
17430 if (it == bjdtype.end())
17434 CharType dtype = it->second;
17436 key =
"_ArraySize_";
17437 std::size_t len = (
value.at(
key).empty() ? 0 : 1);
17438 for (
const auto& el :
value.at(
key))
17440 len *=
static_cast<std::size_t
>(el.m_data.m_value.number_unsigned);
17443 key =
"_ArrayData_";
17449 oa->write_character(
'[');
17450 oa->write_character(
'$');
17451 oa->write_character(dtype);
17452 oa->write_character(
'#');
17454 key =
"_ArraySize_";
17455 write_ubjson(
value.at(
key), use_count, use_type,
true,
true, bjdata_version);
17457 key =
"_ArrayData_";
17458 if (dtype ==
'U' || dtype ==
'C' || dtype ==
'B')
17460 for (
const auto& el :
value.at(
key))
17462 write_number(
static_cast<std::uint8_t
>(el.m_data.m_value.number_unsigned),
true);
17465 else if (dtype ==
'i')
17467 for (
const auto& el :
value.at(
key))
17469 write_number(
static_cast<std::int8_t
>(el.m_data.m_value.number_integer),
true);
17472 else if (dtype ==
'u')
17474 for (
const auto& el :
value.at(
key))
17476 write_number(
static_cast<std::uint16_t
>(el.m_data.m_value.number_unsigned),
true);
17479 else if (dtype ==
'I')
17481 for (
const auto& el :
value.at(
key))
17483 write_number(
static_cast<std::int16_t
>(el.m_data.m_value.number_integer),
true);
17486 else if (dtype ==
'm')
17488 for (
const auto& el :
value.at(
key))
17490 write_number(
static_cast<std::uint32_t
>(el.m_data.m_value.number_unsigned),
true);
17493 else if (dtype ==
'l')
17495 for (
const auto& el :
value.at(
key))
17497 write_number(
static_cast<std::int32_t
>(el.m_data.m_value.number_integer),
true);
17500 else if (dtype ==
'M')
17502 for (
const auto& el :
value.at(
key))
17504 write_number(
static_cast<std::uint64_t
>(el.m_data.m_value.number_unsigned),
true);
17507 else if (dtype ==
'L')
17509 for (
const auto& el :
value.at(
key))
17511 write_number(
static_cast<std::int64_t
>(el.m_data.m_value.number_integer),
true);
17514 else if (dtype ==
'd')
17516 for (
const auto& el :
value.at(
key))
17518 write_number(
static_cast<float>(el.m_data.m_value.number_float),
true);
17521 else if (dtype ==
'D')
17523 for (
const auto& el :
value.at(
key))
17525 write_number(
static_cast<double>(el.m_data.m_value.number_float),
true);
17548 template<
typename NumberType>
17549 void write_number(
const NumberType n,
const bool OutputIsLittleEndian =
false)
17552 std::array<CharType,
sizeof(NumberType)> vec{};
17553 std::memcpy(vec.data(), &n,
sizeof(NumberType));
17556 if (is_little_endian != OutputIsLittleEndian)
17559 std::reverse(vec.begin(), vec.end());
17562 oa->write_characters(vec.data(),
sizeof(NumberType));
17568#pragma GCC diagnostic push
17569#pragma GCC diagnostic ignored "-Wfloat-equal"
17571 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
17572 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
17573 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
17576 ? get_cbor_float_prefix(
static_cast<float>(n))
17577 : get_msgpack_float_prefix(
static_cast<float>(n)));
17578 write_number(
static_cast<float>(n));
17583 ? get_cbor_float_prefix(n)
17584 : get_msgpack_float_prefix(n));
17588#pragma GCC diagnostic pop
17597 template <
typename C = CharType,
17598 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
17601 return *
reinterpret_cast<char*
>(&x);
17604 template <
typename C = CharType,
17605 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
17608 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
17609 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
17611 std::memcpy(&result, &x,
sizeof(x));
17615 template<
typename C = CharType,
17622 template <
typename InputCharType,
typename C = CharType,
17624 std::is_signed<C>::value &&
17625 std::is_signed<char>::value &&
17626 std::is_same<char, typename std::remove_cv<InputCharType>::type>
::value
17658#include <algorithm>
17668#include <type_traits>
17688#include <type_traits>
17719template<
typename Target,
typename Source>
17722 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
17725 std::memcpy(&target, &source,
sizeof(Source));
17736 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_),
e(e_) {}
17747 return {x.f - y.f, x.e};
17756 static_assert(
kPrecision == 64,
"internal error");
17781 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
17782 const std::uint64_t u_hi = x.f >> 32u;
17783 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
17784 const std::uint64_t v_hi = y.f >> 32u;
17786 const std::uint64_t p0 = u_lo * v_lo;
17787 const std::uint64_t p1 = u_lo * v_hi;
17788 const std::uint64_t p2 = u_hi * v_lo;
17789 const std::uint64_t p3 = u_hi * v_hi;
17791 const std::uint64_t p0_hi = p0 >> 32u;
17792 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
17793 const std::uint64_t p1_hi = p1 >> 32u;
17794 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
17795 const std::uint64_t p2_hi = p2 >> 32u;
17797 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
17808 Q += std::uint64_t{1} << (64u - 32u - 1u);
17810 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
17812 return {h, x.e + y.e + 64};
17823 while ((x.f >> 63u) == 0)
17838 const int delta = x.e - target_exponent;
17843 return {x.f << delta, target_exponent};
17860template<
typename FloatType>
17873 static_assert(std::numeric_limits<FloatType>::is_iec559,
17874 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
17876 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
17877 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
17878 constexpr int kMinExp = 1 - kBias;
17879 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
17881 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
17884 const std::uint64_t E = bits >> (kPrecision - 1);
17885 const std::uint64_t F = bits & (kHiddenBit - 1);
17887 const bool is_denormal = E == 0;
17888 const diyfp v = is_denormal
17889 ?
diyfp(F, kMinExp)
17890 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
17913 const bool lower_boundary_is_closer = F == 0 && E > 1;
17915 const diyfp m_minus = lower_boundary_is_closer
17916 ?
diyfp((4 * v.
f) - 1, v.
e - 2)
17917 :
diyfp((2 * v.
f) - 1, v.
e - 1);
18052 constexpr int kCachedPowersMinDecExp = -300;
18053 constexpr int kCachedPowersDecStep = 8;
18055 static constexpr std::array<cached_power, 79> kCachedPowers =
18058 { 0xAB70FE17C79AC6CA, -1060, -300 },
18059 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
18060 { 0xBE5691EF416BD60C, -1007, -284 },
18061 { 0x8DD01FAD907FFC3C, -980, -276 },
18062 { 0xD3515C2831559A83, -954, -268 },
18063 { 0x9D71AC8FADA6C9B5, -927, -260 },
18064 { 0xEA9C227723EE8BCB, -901, -252 },
18065 { 0xAECC49914078536D, -874, -244 },
18066 { 0x823C12795DB6CE57, -847, -236 },
18067 { 0xC21094364DFB5637, -821, -228 },
18068 { 0x9096EA6F3848984F, -794, -220 },
18069 { 0xD77485CB25823AC7, -768, -212 },
18070 { 0xA086CFCD97BF97F4, -741, -204 },
18071 { 0xEF340A98172AACE5, -715, -196 },
18072 { 0xB23867FB2A35B28E, -688, -188 },
18073 { 0x84C8D4DFD2C63F3B, -661, -180 },
18074 { 0xC5DD44271AD3CDBA, -635, -172 },
18075 { 0x936B9FCEBB25C996, -608, -164 },
18076 { 0xDBAC6C247D62A584, -582, -156 },
18077 { 0xA3AB66580D5FDAF6, -555, -148 },
18078 { 0xF3E2F893DEC3F126, -529, -140 },
18079 { 0xB5B5ADA8AAFF80B8, -502, -132 },
18080 { 0x87625F056C7C4A8B, -475, -124 },
18081 { 0xC9BCFF6034C13053, -449, -116 },
18082 { 0x964E858C91BA2655, -422, -108 },
18083 { 0xDFF9772470297EBD, -396, -100 },
18084 { 0xA6DFBD9FB8E5B88F, -369, -92 },
18085 { 0xF8A95FCF88747D94, -343, -84 },
18086 { 0xB94470938FA89BCF, -316, -76 },
18087 { 0x8A08F0F8BF0F156B, -289, -68 },
18088 { 0xCDB02555653131B6, -263, -60 },
18089 { 0x993FE2C6D07B7FAC, -236, -52 },
18090 { 0xE45C10C42A2B3B06, -210, -44 },
18091 { 0xAA242499697392D3, -183, -36 },
18092 { 0xFD87B5F28300CA0E, -157, -28 },
18093 { 0xBCE5086492111AEB, -130, -20 },
18094 { 0x8CBCCC096F5088CC, -103, -12 },
18095 { 0xD1B71758E219652C, -77, -4 },
18096 { 0x9C40000000000000, -50, 4 },
18097 { 0xE8D4A51000000000, -24, 12 },
18098 { 0xAD78EBC5AC620000, 3, 20 },
18099 { 0x813F3978F8940984, 30, 28 },
18100 { 0xC097CE7BC90715B3, 56, 36 },
18101 { 0x8F7E32CE7BEA5C70, 83, 44 },
18102 { 0xD5D238A4ABE98068, 109, 52 },
18103 { 0x9F4F2726179A2245, 136, 60 },
18104 { 0xED63A231D4C4FB27, 162, 68 },
18105 { 0xB0DE65388CC8ADA8, 189, 76 },
18106 { 0x83C7088E1AAB65DB, 216, 84 },
18107 { 0xC45D1DF942711D9A, 242, 92 },
18108 { 0x924D692CA61BE758, 269, 100 },
18109 { 0xDA01EE641A708DEA, 295, 108 },
18110 { 0xA26DA3999AEF774A, 322, 116 },
18111 { 0xF209787BB47D6B85, 348, 124 },
18112 { 0xB454E4A179DD1877, 375, 132 },
18113 { 0x865B86925B9BC5C2, 402, 140 },
18114 { 0xC83553C5C8965D3D, 428, 148 },
18115 { 0x952AB45CFA97A0B3, 455, 156 },
18116 { 0xDE469FBD99A05FE3, 481, 164 },
18117 { 0xA59BC234DB398C25, 508, 172 },
18118 { 0xF6C69A72A3989F5C, 534, 180 },
18119 { 0xB7DCBF5354E9BECE, 561, 188 },
18120 { 0x88FCF317F22241E2, 588, 196 },
18121 { 0xCC20CE9BD35C78A5, 614, 204 },
18122 { 0x98165AF37B2153DF, 641, 212 },
18123 { 0xE2A0B5DC971F303A, 667, 220 },
18124 { 0xA8D9D1535CE3B396, 694, 228 },
18125 { 0xFB9B7CD9A4A7443C, 720, 236 },
18126 { 0xBB764C4CA7A44410, 747, 244 },
18127 { 0x8BAB8EEFB6409C1A, 774, 252 },
18128 { 0xD01FEF10A657842C, 800, 260 },
18129 { 0x9B10A4E5E9913129, 827, 268 },
18130 { 0xE7109BFBA19C0C9D, 853, 276 },
18131 { 0xAC2820D9623BF429, 880, 284 },
18132 { 0x80444B5E7AA7CF85, 907, 292 },
18133 { 0xBF21E44003ACDD2D, 933, 300 },
18134 { 0x8E679C2F5E44FF8F, 960, 308 },
18135 { 0xD433179D9C8CB841, 986, 316 },
18136 { 0x9E19DB92B4E31BA9, 1013, 324 },
18146 const int f =
kAlpha - e - 1;
18147 const int k = ((f * 78913) / (1 << 18)) +
static_cast<int>(f > 0);
18149 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
18151 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
18153 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
18167 if (n >= 1000000000)
18169 pow10 = 1000000000;
18173 if (n >= 100000000)
18218inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
18219 std::uint64_t rest, std::uint64_t ten_k)
18246 && delta - rest >= ten_k
18247 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
18262 static_assert(
kAlpha >= -60,
"internal error");
18263 static_assert(
kGamma <= -32,
"internal error");
18280 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).f;
18281 std::uint64_t dist =
diyfp::sub(M_plus, w ).f;
18290 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
18292 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
18293 std::uint64_t p2 = M_plus.
f & (one.f - 1);
18301 std::uint32_t pow10{};
18329 const std::uint32_t d = p1 / pow10;
18330 const std::uint32_t r = p1 % pow10;
18336 buffer[length++] =
static_cast<char>(
'0' + d);
18355 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
18360 decimal_exponent += n;
18371 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
18372 grisu2_round(buffer, length, dist, delta, rest, ten_n);
18433 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
18435 const std::uint64_t d = p2 >> -one.e;
18436 const std::uint64_t r = p2 & (one.f - 1);
18443 buffer[length++] =
static_cast<char>(
'0' + d);
18468 decimal_exponent -= m;
18476 const std::uint64_t ten_m = one.f;
18500inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
18517 const diyfp c_minus_k(cached.
f, cached.
e);
18545 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
18546 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
18548 decimal_exponent = -cached.
k;
18558template<
typename FloatType>
18563 "internal error: not enough precision");
18615 auto k =
static_cast<std::uint32_t
>(e);
18621 *buf++ =
static_cast<char>(
'0' + k);
18625 *buf++ =
static_cast<char>(
'0' + (k / 10));
18627 *buf++ =
static_cast<char>(
'0' + k);
18631 *buf++ =
static_cast<char>(
'0' + (k / 100));
18633 *buf++ =
static_cast<char>(
'0' + (k / 10));
18635 *buf++ =
static_cast<char>(
'0' + k);
18653 int min_exp,
int max_exp)
18659 const int n = len + decimal_exponent;
18665 if (k <= n && n <= max_exp)
18670 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
18674 return buf + (
static_cast<size_t>(n) + 2);
18677 if (0 < n && n <= max_exp)
18684 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
18686 return buf + (
static_cast<size_t>(k) + 1U);
18689 if (min_exp < n && n <= 0)
18694 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
18697 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
18698 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
18713 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
18715 buf += 1 +
static_cast<size_t>(k);
18734template<
typename FloatType>
18739 static_cast<void>(last);
18743 if (std::signbit(
value))
18750#pragma GCC diagnostic push
18751#pragma GCC diagnostic ignored "-Wfloat-equal"
18762#pragma GCC diagnostic pop
18765 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
18772 int decimal_exponent = 0;
18775 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
18778 constexpr int kMinExp = -4;
18780 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
18783 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
18784 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
18823template<
typename BasicJsonType>
18826 using string_t =
typename BasicJsonType::string_t;
18827 using number_float_t =
typename BasicJsonType::number_float_t;
18828 using number_integer_t =
typename BasicJsonType::number_integer_t;
18829 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18830 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
18831 static constexpr std::uint8_t UTF8_ACCEPT = 0;
18832 static constexpr std::uint8_t UTF8_REJECT = 1;
18843 ,
loc(
std::localeconv())
18881 const bool pretty_print,
18883 const unsigned int indent_step,
18884 const unsigned int current_indent = 0)
18886 switch (val.m_data.m_type)
18890 if (val.m_data.m_value.object->empty())
18892 o->write_characters(
"{}", 2);
18898 o->write_characters(
"{\n", 2);
18901 const auto new_indent = current_indent + indent_step;
18908 auto i = val.m_data.m_value.object->cbegin();
18909 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18912 o->write_character(
'\"');
18914 o->write_characters(
"\": ", 3);
18916 o->write_characters(
",\n", 2);
18920 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18921 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18923 o->write_character(
'\"');
18925 o->write_characters(
"\": ", 3);
18928 o->write_character(
'\n');
18929 o->write_characters(
indent_string.c_str(), current_indent);
18930 o->write_character(
'}');
18934 o->write_character(
'{');
18937 auto i = val.m_data.m_value.object->cbegin();
18938 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18940 o->write_character(
'\"');
18942 o->write_characters(
"\":", 2);
18944 o->write_character(
',');
18948 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18949 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18950 o->write_character(
'\"');
18952 o->write_characters(
"\":", 2);
18955 o->write_character(
'}');
18963 if (val.m_data.m_value.array->empty())
18965 o->write_characters(
"[]", 2);
18971 o->write_characters(
"[\n", 2);
18974 const auto new_indent = current_indent + indent_step;
18981 for (
auto i = val.m_data.m_value.array->cbegin();
18982 i != val.m_data.m_value.array->cend() - 1; ++i)
18986 o->write_characters(
",\n", 2);
18992 dump(val.m_data.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
18994 o->write_character(
'\n');
18995 o->write_characters(
indent_string.c_str(), current_indent);
18996 o->write_character(
']');
19000 o->write_character(
'[');
19003 for (
auto i = val.m_data.m_value.array->cbegin();
19004 i != val.m_data.m_value.array->cend() - 1; ++i)
19007 o->write_character(
',');
19012 dump(val.m_data.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
19014 o->write_character(
']');
19022 o->write_character(
'\"');
19023 dump_escaped(*val.m_data.m_value.string,
ensure_ascii);
19024 o->write_character(
'\"');
19032 o->write_characters(
"{\n", 2);
19035 const auto new_indent = current_indent + indent_step;
19043 o->write_characters(
"\"bytes\": [", 10);
19045 if (!val.m_data.m_value.binary->empty())
19047 for (
auto i = val.m_data.m_value.binary->cbegin();
19048 i != val.m_data.m_value.binary->cend() - 1; ++i)
19051 o->write_characters(
", ", 2);
19053 dump_integer(val.m_data.m_value.binary->back());
19056 o->write_characters(
"],\n", 3);
19059 o->write_characters(
"\"subtype\": ", 11);
19060 if (val.m_data.m_value.binary->has_subtype())
19062 dump_integer(val.m_data.m_value.binary->subtype());
19066 o->write_characters(
"null", 4);
19068 o->write_character(
'\n');
19069 o->write_characters(
indent_string.c_str(), current_indent);
19070 o->write_character(
'}');
19074 o->write_characters(
"{\"bytes\":[", 10);
19076 if (!val.m_data.m_value.binary->empty())
19078 for (
auto i = val.m_data.m_value.binary->cbegin();
19079 i != val.m_data.m_value.binary->cend() - 1; ++i)
19082 o->write_character(
',');
19084 dump_integer(val.m_data.m_value.binary->back());
19087 o->write_characters(
"],\"subtype\":", 12);
19088 if (val.m_data.m_value.binary->has_subtype())
19090 dump_integer(val.m_data.m_value.binary->subtype());
19091 o->write_character(
'}');
19095 o->write_characters(
"null}", 5);
19103 if (val.m_data.m_value.boolean)
19105 o->write_characters(
"true", 4);
19109 o->write_characters(
"false", 5);
19116 dump_integer(val.m_data.m_value.number_integer);
19122 dump_integer(val.m_data.m_value.number_unsigned);
19128 dump_float(val.m_data.m_value.number_float);
19134 o->write_characters(
"<discarded>", 11);
19140 o->write_characters(
"null", 4);
19166 std::uint32_t codepoint{};
19174 for (std::size_t i = 0; i < s.size(); ++i)
19176 const auto byte =
static_cast<std::uint8_t
>(s[i]);
19178 switch (decode(
state, codepoint,
byte))
19237 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
19239 if (codepoint <= 0xFFFF)
19243 static_cast<std::uint16_t
>(codepoint)));
19249 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
19250 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
19251 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
19339 state = UTF8_ACCEPT;
19395 o->write_characters(
"\\ufffd", 6);
19399 o->write_characters(
"\xEF\xBF\xBD", 3);
19419 unsigned int count_digits(number_unsigned_t x)
noexcept
19421 unsigned int n_digits = 1;
19430 return n_digits + 1;
19434 return n_digits + 2;
19438 return n_digits + 3;
19450 static std::string hex_bytes(std::uint8_t
byte)
19452 std::string result =
"FF";
19453 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
19454 result[0] = nibble_to_hex[
byte / 16];
19455 result[1] = nibble_to_hex[
byte % 16];
19460 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
19461 bool is_negative_number(NumberType x)
19466 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
19467 bool is_negative_number(NumberType )
19482 std::is_integral<NumberType>::value ||
19483 std::is_same<NumberType, number_unsigned_t>::value ||
19484 std::is_same<NumberType, number_integer_t>::value ||
19485 std::is_same<NumberType, binary_char_t>::value,
19487 void dump_integer(NumberType x)
19489 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
19492 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
19493 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
19494 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
19495 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
19496 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
19497 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
19498 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
19499 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
19500 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
19501 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
19508 o->write_character(
'0');
19513 auto buffer_ptr = number_buffer.begin();
19515 number_unsigned_t abs_value;
19517 unsigned int n_chars{};
19519 if (is_negative_number(x))
19522 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
19525 n_chars = 1 + count_digits(abs_value);
19529 abs_value =
static_cast<number_unsigned_t
>(x);
19530 n_chars = count_digits(abs_value);
19538 buffer_ptr +=
static_cast<typename decltype(number_buffer)::difference_type
>(n_chars);
19542 while (abs_value >= 100)
19544 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
19546 *(--buffer_ptr) = digits_to_99[digits_index][1];
19547 *(--buffer_ptr) = digits_to_99[digits_index][0];
19550 if (abs_value >= 10)
19552 const auto digits_index =
static_cast<unsigned>(abs_value);
19553 *(--buffer_ptr) = digits_to_99[digits_index][1];
19554 *(--buffer_ptr) = digits_to_99[digits_index][0];
19558 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
19561 o->write_characters(number_buffer.data(), n_chars);
19572 void dump_float(number_float_t x)
19575 if (!std::isfinite(x))
19577 o->write_characters(
"null", 4);
19586 static constexpr bool is_ieee_single_or_double
19587 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
19588 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
19590 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
19593 void dump_float(number_float_t x, std::true_type )
19595 auto* begin = number_buffer.data();
19596 auto* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x);
19598 o->write_characters(begin,
static_cast<size_t>(end - begin));
19601 void dump_float(number_float_t x, std::false_type )
19604 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
19608 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
19613 JSON_ASSERT(
static_cast<std::size_t
>(len) < number_buffer.size());
19616 if (thousands_sep !=
'\0')
19619 const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
19620 std::fill(end, number_buffer.end(),
'\0');
19621 JSON_ASSERT((end - number_buffer.begin()) <= len);
19622 len = (end - number_buffer.begin());
19626 if (decimal_point !=
'\0' && decimal_point !=
'.')
19629 const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
19630 if (dec_pos != number_buffer.end())
19636 o->write_characters(number_buffer.data(),
static_cast<std::size_t
>(len));
19639 const bool value_is_int_like =
19640 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
19643 return c ==
'.' || c ==
'e';
19646 if (value_is_int_like)
19648 o->write_characters(
".0", 2);
19673 static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
19675 static const std::array<std::uint8_t, 400> utf8d =
19678 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19679 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19680 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19681 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19682 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
19683 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
19684 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
19685 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
19686 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
19687 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
19688 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
19689 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
19690 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
19691 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
19696 const std::uint8_t type = utf8d[byte];
19698 codep = (state != UTF8_ACCEPT)
19699 ? (
byte & 0x3fu) | (codep << 6u)
19700 : (0xFFu >> type) & (byte);
19702 const std::size_t index = 256u + (
static_cast<size_t>(state) * 16u) +
static_cast<size_t>(type);
19704 state = utf8d[index];
19713 number_unsigned_t remove_sign(number_unsigned_t x)
19728 number_unsigned_t remove_sign(number_integer_t x)
noexcept
19730 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
19731 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
19736 output_adapter_t<char> o =
nullptr;
19778#include <functional>
19779#include <initializer_list>
19782#include <stdexcept>
19783#include <type_traits>
19796template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
19797 class Allocator = std::allocator<std::pair<const Key, T>>>
19802 using Container = std::vector<std::pair<const Key, T>, Allocator>;
19807#ifdef JSON_HAS_CPP_14
19817 template <
class It>
19820 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
19825 for (
auto it = this->begin(); it != this->end(); ++it)
19827 if (m_compare(it->first, key))
19829 return {it,
false};
19832 Container::emplace_back(key, std::forward<T>(t));
19833 return {std::prev(this->end()),
true};
19838 std::pair<iterator, bool>
emplace(KeyType && key, T && t)
19840 for (
auto it = this->begin(); it != this->end(); ++it)
19842 if (m_compare(it->first, key))
19844 return {it,
false};
19847 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
19848 return {std::prev(this->end()),
true};
19853 return emplace(key, T{}).first->second;
19860 return emplace(std::forward<KeyType>(key), T{}).first->second;
19872 return at(std::forward<KeyType>(key));
19877 for (
auto it = this->begin(); it != this->end(); ++it)
19879 if (m_compare(it->first, key))
19885 JSON_THROW(std::out_of_range(
"key not found"));
19892 for (
auto it = this->begin(); it != this->end(); ++it)
19894 if (m_compare(it->first, key))
19900 JSON_THROW(std::out_of_range(
"key not found"));
19905 for (
auto it = this->begin(); it != this->end(); ++it)
19907 if (m_compare(it->first, key))
19913 JSON_THROW(std::out_of_range(
"key not found"));
19918 const T &
at(KeyType && key)
const
19920 for (
auto it = this->begin(); it != this->end(); ++it)
19922 if (m_compare(it->first, key))
19928 JSON_THROW(std::out_of_range(
"key not found"));
19933 for (
auto it = this->begin(); it != this->end(); ++it)
19935 if (m_compare(it->first, key))
19938 for (
auto next = it; ++next != this->end(); ++it)
19943 Container::pop_back();
19954 for (
auto it = this->begin(); it != this->end(); ++it)
19956 if (m_compare(it->first, key))
19959 for (
auto next = it; ++next != this->end(); ++it)
19964 Container::pop_back();
19973 return erase(pos, std::next(pos));
19983 const auto elements_affected = std::distance(first, last);
19984 const auto offset = std::distance(Container::begin(), first);
20006 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
20009 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
20017 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
20026 return Container::begin() + offset;
20031 for (
auto it = this->begin(); it != this->end(); ++it)
20033 if (m_compare(it->first, key))
20045 for (
auto it = this->begin(); it != this->end(); ++it)
20047 if (m_compare(it->first, key))
20057 for (
auto it = this->begin(); it != this->end(); ++it)
20059 if (m_compare(it->first, key))
20064 return Container::end();
20071 for (
auto it = this->begin(); it != this->end(); ++it)
20073 if (m_compare(it->first, key))
20078 return Container::end();
20083 for (
auto it = this->begin(); it != this->end(); ++it)
20085 if (m_compare(it->first, key))
20090 return Container::end();
20095 return emplace(value.first, std::move(value.second));
20100 for (
auto it = this->begin(); it != this->end(); ++it)
20102 if (m_compare(it->first, value.first))
20104 return {it,
false};
20107 Container::push_back(value);
20108 return {--this->end(),
true};
20111 template<
typename InputIt>
20112 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
20113 std::input_iterator_tag>::value>::type;
20115 template<
typename InputIt,
typename = require_input_iter<InputIt>>
20118 for (
auto it = first; it != last; ++it)
20131#if defined(JSON_HAS_CPP_17)
20132 #if JSON_HAS_STATIC_RTTI
20135 #include <string_view>
20165 :
public ::nlohmann::detail::json_base_class<CustomBaseClass>
20171 friend class ::nlohmann::json_pointer;
20175 template<
typename BasicJsonType,
typename InputType>
20176 friend class ::nlohmann::detail::parser;
20177 friend ::nlohmann::detail::serializer<basic_json>;
20178 template<
typename BasicJsonType>
20179 friend class ::nlohmann::detail::iter_impl;
20180 template<
typename BasicJsonType,
typename CharType>
20181 friend class ::nlohmann::detail::binary_writer;
20182 template<
typename BasicJsonType,
typename InputType,
typename SAX>
20183 friend class ::nlohmann::detail::binary_reader;
20184 template<
typename BasicJsonType,
typename InputAdapterType>
20185 friend class ::nlohmann::detail::json_sax_dom_parser;
20186 template<
typename BasicJsonType,
typename InputAdapterType>
20187 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
20188 friend class ::nlohmann::detail::exception;
20192 using json_base_class_t = ::nlohmann::detail::json_base_class<CustomBaseClass>;
20196 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
20198 template<
typename InputAdapterType>
20199 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
20200 InputAdapterType adapter,
20202 const bool allow_exceptions =
true,
20203 const bool ignore_comments =
false
20206 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
20207 std::move(cb), allow_exceptions, ignore_comments);
20211 using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
20212 template<
typename BasicJsonType>
20213 using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>;
20214 template<
typename BasicJsonType>
20215 using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>;
20216 template<
typename Iterator>
20217 using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>;
20218 template<
typename Base>
using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>;
20220 template<
typename CharType>
20221 using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
20223 template<
typename InputType>
20224 using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>;
20225 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
20228 using serializer = ::nlohmann::detail::serializer<basic_json>;
20234 template<
typename T,
typename SFINAE>
20292 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
20294 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
20321 result[
"copyright"] =
"(C) 2013-2025 Niels Lohmann";
20322 result[
"name"] =
"JSON for Modern C++";
20323 result[
"url"] =
"https://github.com/nlohmann/json";
20324 result[
"version"][
"string"] =
20333 result[
"platform"] =
"win32";
20334#elif defined __linux__
20335 result[
"platform"] =
"linux";
20336#elif defined __APPLE__
20337 result[
"platform"] =
"apple";
20338#elif defined __unix__
20339 result[
"platform"] =
"unix";
20341 result[
"platform"] =
"unknown";
20344#if defined(__ICC) || defined(__INTEL_COMPILER)
20345 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
20346#elif defined(__clang__)
20347 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
20348#elif defined(__GNUC__) || defined(__GNUG__)
20349 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
20350 std::to_string(__GNUC__),
'.',
20351 std::to_string(__GNUC_MINOR__),
'.',
20352 std::to_string(__GNUC_PATCHLEVEL__))
20355#elif defined(__HP_cc) || defined(__HP_aCC)
20356 result[
"compiler"] =
"hp"
20357#elif defined(__IBMCPP__)
20358 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
20359#elif defined(_MSC_VER)
20360 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
20361#elif defined(__PGI)
20362 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
20363#elif defined(__SUNPRO_CC)
20364 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
20366 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
20369#if defined(_MSVC_LANG)
20370 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
20371#elif defined(__cplusplus)
20372 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
20374 result[
"compiler"][
"c++"] =
"unknown";
20392#if defined(JSON_HAS_CPP_14)
20395 using default_object_comparator_t = std::less<>;
20405 AllocatorType<std::pair<
const StringType,
20410 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
20434 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
20445 template<
typename T,
typename... Args>
20447 static T* create(Args&& ... args)
20449 AllocatorType<T> alloc;
20450 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
20452 auto deleter = [&](T * obj)
20454 AllocatorTraits::deallocate(alloc, obj, 1);
20456 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
20457 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
20459 return obj.release();
20505 number_integer_t number_integer;
20507 number_unsigned_t number_unsigned;
20509 number_float_t number_float;
20512 json_value() =
default;
20514 json_value(boolean_t v) noexcept : boolean(v) {}
20520 json_value(number_float_t v) noexcept :
number_float(v) {}
20522 json_value(value_t t)
20526 case value_t::object:
20528 object = create<object_t>();
20532 case value_t::array:
20534 array = create<array_t>();
20538 case value_t::string:
20540 string = create<string_t>(
"");
20544 case value_t::binary:
20546 binary = create<binary_t>();
20550 case value_t::boolean:
20552 boolean =
static_cast<boolean_t
>(
false);
20556 case value_t::number_integer:
20562 case value_t::number_unsigned:
20568 case value_t::number_float:
20574 case value_t::null:
20580 case value_t::discarded:
20586 JSON_THROW(other_error::create(500,
"961c151d2e87f2686a955a9be24d316f1362bf21 3.12.0",
nullptr));
20594 json_value(
const string_t& value) :
string(create<string_t>(
value)) {}
20597 json_value(string_t&& value) :
string(create<string_t>(std::move(
value))) {}
20600 json_value(
const object_t& value) :
object(create<object_t>(
value)) {}
20603 json_value(object_t&& value) :
object(create<object_t>(std::move(
value))) {}
20606 json_value(
const array_t& value) :
array(create<array_t>(
value)) {}
20609 json_value(array_t&& value) :
array(create<array_t>(std::move(
value))) {}
20612 json_value(
const typename binary_t::container_type& value) :
binary(create<binary_t>(
value)) {}
20615 json_value(
typename binary_t::container_type&& value) :
binary(create<binary_t>(std::move(
value))) {}
20618 json_value(
const binary_t& value) :
binary(create<binary_t>(
value)) {}
20621 json_value(binary_t&& value) :
binary(create<binary_t>(std::move(
value))) {}
20623 void destroy(value_t t)
20626 (t == value_t::object &&
object ==
nullptr) ||
20627 (t == value_t::array && array ==
nullptr) ||
20628 (t == value_t::string &&
string ==
nullptr) ||
20629 (t == value_t::binary && binary ==
nullptr)
20635 if (t == value_t::array || t == value_t::object)
20638 std::vector<basic_json> stack;
20641 if (t == value_t::array)
20643 stack.reserve(
array->size());
20644 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
20648 stack.reserve(
object->size());
20649 for (
auto&& it : *
object)
20651 stack.push_back(std::move(it.second));
20655 while (!stack.empty())
20658 basic_json current_item(std::move(stack.back()));
20663 if (current_item.is_array())
20665 std::move(current_item.m_data.m_value.array->begin(), current_item.m_data.m_value.array->end(), std::back_inserter(stack));
20667 current_item.m_data.m_value.array->clear();
20669 else if (current_item.is_object())
20671 for (
auto&& it : *current_item.m_data.m_value.object)
20673 stack.push_back(std::move(it.second));
20676 current_item.m_data.m_value.object->clear();
20686 case value_t::object:
20688 AllocatorType<object_t> alloc;
20689 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
20690 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
20694 case value_t::array:
20696 AllocatorType<array_t> alloc;
20697 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
20698 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
20702 case value_t::string:
20704 AllocatorType<string_t> alloc;
20705 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
20706 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
20710 case value_t::binary:
20712 AllocatorType<binary_t> alloc;
20713 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
20714 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
20718 case value_t::null:
20719 case value_t::boolean:
20720 case value_t::number_integer:
20721 case value_t::number_unsigned:
20722 case value_t::number_float:
20723 case value_t::discarded:
20751 void assert_invariant(
bool check_parents =
true) const noexcept
20753 JSON_ASSERT(m_data.m_type != value_t::object || m_data.m_value.object !=
nullptr);
20754 JSON_ASSERT(m_data.m_type != value_t::array || m_data.m_value.array !=
nullptr);
20755 JSON_ASSERT(m_data.m_type != value_t::string || m_data.m_value.string !=
nullptr);
20756 JSON_ASSERT(m_data.m_type != value_t::binary || m_data.m_value.binary !=
nullptr);
20758#if JSON_DIAGNOSTICS
20762 JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [
this](
const basic_json & j)
20764 return j.m_parent ==
this;
20769 static_cast<void>(check_parents);
20774#if JSON_DIAGNOSTICS
20775 switch (m_data.m_type)
20777 case value_t::array:
20779 for (
auto& element : *m_data.m_value.array)
20781 element.m_parent =
this;
20786 case value_t::object:
20788 for (
auto& element : *m_data.m_value.object)
20790 element.second.m_parent =
this;
20795 case value_t::null:
20796 case value_t::string:
20797 case value_t::boolean:
20798 case value_t::number_integer:
20799 case value_t::number_unsigned:
20800 case value_t::number_float:
20801 case value_t::binary:
20802 case value_t::discarded:
20809 iterator set_parents(iterator it,
typename iterator::difference_type count_set_parents)
20811#if JSON_DIAGNOSTICS
20812 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
20814 (it + i)->m_parent =
this;
20817 static_cast<void>(count_set_parents);
20824#if JSON_DIAGNOSTICS
20839#ifdef JSON_HEDLEY_MSVC_VERSION
20840#pragma warning(push )
20841#pragma warning(disable : 4127)
20848#ifdef JSON_HEDLEY_MSVC_VERSION
20849#pragma warning( pop )
20854 static_cast<void>(j);
20855 static_cast<void>(old_capacity);
20887 assert_invariant();
20895 assert_invariant();
20900 template <
typename CompatibleType,
20905 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
20906 std::forward<CompatibleType>(val))))
20908 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
20910 assert_invariant();
20915 template <
typename BasicJsonType,
20919#if JSON_DIAGNOSTIC_POSITIONS
20920 : start_position(val.start_pos()),
20921 end_position(val.end_pos())
20924 using other_boolean_t =
typename BasicJsonType::boolean_t;
20925 using other_number_float_t =
typename BasicJsonType::number_float_t;
20926 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20927 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20928 using other_string_t =
typename BasicJsonType::string_t;
20929 using other_object_t =
typename BasicJsonType::object_t;
20930 using other_array_t =
typename BasicJsonType::array_t;
20931 using other_binary_t =
typename BasicJsonType::binary_t;
20933 switch (val.type())
20935 case value_t::boolean:
20938 case value_t::number_float:
20941 case value_t::number_integer:
20944 case value_t::number_unsigned:
20947 case value_t::string:
20950 case value_t::object:
20953 case value_t::array:
20956 case value_t::binary:
20959 case value_t::null:
20962 case value_t::discarded:
20963 m_data.m_type = value_t::discarded;
20971 assert_invariant();
20977 bool type_deduction =
true,
20978 value_t manual_type = value_t::array)
20982 bool is_an_object = std::all_of(init.begin(), init.end(),
20988 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
20992 if (!type_deduction)
20995 if (manual_type == value_t::array)
20997 is_an_object =
false;
21010 m_data.m_type = value_t::object;
21011 m_data.m_value = value_t::object;
21013 for (
auto& element_ref : init)
21016 m_data.m_value.object->emplace(
21017 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
21018 std::move((*element.m_data.m_value.array)[1]));
21024 m_data.m_type = value_t::array;
21025 m_data.m_value.array = create<array_t>(init.begin(), init.end());
21029 assert_invariant();
21038 res.m_data.m_type = value_t::binary;
21039 res.m_data.m_value = init;
21046 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
21049 res.m_data.m_type = value_t::binary;
21050 res.m_data.m_value =
binary_t(init, subtype);
21060 res.m_data.m_type = value_t::binary;
21061 res.m_data.m_value = std::move(init);
21068 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
21071 res.m_data.m_type = value_t::binary;
21072 res.m_data.m_value =
binary_t(std::move(init), subtype);
21081 return basic_json(init,
false, value_t::array);
21089 return basic_json(init,
false, value_t::object);
21098 assert_invariant();
21103 template <
class InputIT,
typename std::enable_if <
21104 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
21105 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >::type = 0 >
21118 m_data.m_type = first.m_object->m_data.m_type;
21123 case value_t::boolean:
21124 case value_t::number_float:
21125 case value_t::number_integer:
21126 case value_t::number_unsigned:
21127 case value_t::string:
21130 || !last.m_it.primitive_iterator.is_end()))
21137 case value_t::null:
21138 case value_t::object:
21139 case value_t::array:
21140 case value_t::binary:
21141 case value_t::discarded:
21148 case value_t::number_integer:
21150 m_data.m_value.number_integer = first.m_object->m_data.m_value.number_integer;
21154 case value_t::number_unsigned:
21156 m_data.m_value.number_unsigned = first.m_object->m_data.m_value.number_unsigned;
21160 case value_t::number_float:
21162 m_data.m_value.number_float = first.m_object->m_data.m_value.number_float;
21166 case value_t::boolean:
21168 m_data.m_value.boolean = first.m_object->m_data.m_value.boolean;
21172 case value_t::string:
21174 m_data.m_value = *first.m_object->m_data.m_value.string;
21178 case value_t::object:
21180 m_data.m_value.object = create<object_t>(first.m_it.object_iterator,
21181 last.m_it.object_iterator);
21185 case value_t::array:
21187 m_data.m_value.array = create<array_t>(first.m_it.array_iterator,
21188 last.m_it.array_iterator);
21192 case value_t::binary:
21194 m_data.m_value = *first.m_object->m_data.m_value.binary;
21198 case value_t::null:
21199 case value_t::discarded:
21205 assert_invariant();
21212 template<
typename JsonRef,
21214 std::is_same<typename JsonRef::value_type, basic_json>>::value,
int> = 0 >
21220 : json_base_class_t(other)
21222 , start_position(other.start_position)
21223 , end_position(other.end_position)
21228 other.assert_invariant();
21232 case value_t::object:
21234 m_data.m_value = *other.m_data.m_value.object;
21238 case value_t::array:
21240 m_data.m_value = *other.m_data.m_value.array;
21244 case value_t::string:
21246 m_data.m_value = *other.m_data.m_value.string;
21250 case value_t::boolean:
21252 m_data.m_value = other.m_data.m_value.boolean;
21256 case value_t::number_integer:
21258 m_data.m_value = other.m_data.m_value.number_integer;
21262 case value_t::number_unsigned:
21264 m_data.m_value = other.m_data.m_value.number_unsigned;
21268 case value_t::number_float:
21270 m_data.m_value = other.m_data.m_value.number_float;
21274 case value_t::binary:
21276 m_data.m_value = *other.m_data.m_value.binary;
21280 case value_t::null:
21281 case value_t::discarded:
21287 assert_invariant();
21293 : json_base_class_t(std::forward<json_base_class_t>(other)),
21294 m_data(std::move(other.m_data))
21295#if JSON_DIAGNOSTIC_POSITIONS
21296 , start_position(other.start_position)
21297 , end_position(other.end_position)
21301 other.assert_invariant(
false);
21304 other.m_data.m_type = value_t::null;
21305 other.m_data.m_value = {};
21307#if JSON_DIAGNOSTIC_POSITIONS
21308 other.start_position = std::string::npos;
21309 other.end_position = std::string::npos;
21313 assert_invariant();
21319 std::is_nothrow_move_constructible<value_t>::value&&
21320 std::is_nothrow_move_assignable<value_t>::value&&
21321 std::is_nothrow_move_constructible<json_value>::value&&
21322 std::is_nothrow_move_assignable<json_value>::value&&
21323 std::is_nothrow_move_assignable<json_base_class_t>::value
21327 other.assert_invariant();
21333#if JSON_DIAGNOSTIC_POSITIONS
21334 swap(start_position, other.start_position);
21335 swap(end_position, other.end_position);
21338 json_base_class_t::operator=(std::move(other));
21341 assert_invariant();
21349 assert_invariant(
false);
21366 const char indent_char =
' ',
21367 const bool ensure_ascii =
false,
21375 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
21379 s.dump(*
this,
false, ensure_ascii, 0);
21410 return m_data.m_type == value_t::null;
21417 return m_data.m_type == value_t::boolean;
21431 return m_data.m_type == value_t::number_integer ||
m_data.m_type == value_t::number_unsigned;
21438 return m_data.m_type == value_t::number_unsigned;
21445 return m_data.m_type == value_t::number_float;
21452 return m_data.m_type == value_t::object;
21459 return m_data.m_type == value_t::array;
21466 return m_data.m_type == value_t::string;
21473 return m_data.m_type == value_t::binary;
21480 return m_data.m_type == value_t::discarded;
21498 boolean_t get_impl(boolean_t* )
const
21502 return m_data.m_value.boolean;
21509 object_t* get_impl_ptr(object_t* )
noexcept
21511 return is_object() ? m_data.m_value.object :
nullptr;
21515 constexpr const object_t* get_impl_ptr(
const object_t* )
const noexcept
21517 return is_object() ? m_data.m_value.object :
nullptr;
21521 array_t* get_impl_ptr(array_t* )
noexcept
21523 return is_array() ? m_data.m_value.array :
nullptr;
21527 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
21529 return is_array() ? m_data.m_value.array :
nullptr;
21535 return is_string() ? m_data.m_value.string :
nullptr;
21541 return is_string() ? m_data.m_value.string :
nullptr;
21545 boolean_t* get_impl_ptr(boolean_t* )
noexcept
21547 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21551 constexpr const boolean_t* get_impl_ptr(
const boolean_t* )
const noexcept
21553 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
21559 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21565 return m_data.m_type == value_t::number_integer ? &m_data.m_value.number_integer :
nullptr;
21571 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21577 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
21583 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21589 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
21595 return is_binary() ? m_data.m_value.binary :
nullptr;
21601 return is_binary() ? m_data.m_value.binary :
nullptr;
21615 template<
typename ReferenceType,
typename ThisType>
21616 static ReferenceType get_ref_impl(ThisType& obj)
21619 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
21626 JSON_THROW(type_error::create(303,
detail::concat(
"incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj));
21636 template<
typename PointerType,
typename std::enable_if<
21637 std::is_pointer<PointerType>::value,
int>::type = 0>
21638 auto get_ptr() noexcept -> decltype(
std::declval<basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
21641 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21646 template <
typename PointerType,
typename std::enable_if <
21647 std::is_pointer<PointerType>::value&&
21648 std::is_const<typename std::remove_pointer<PointerType>::type>::value,
int >::type = 0 >
21649 constexpr auto get_ptr() const noexcept -> decltype(
std::declval<const basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
21652 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
21694 template <
typename ValueType,
21700 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
21702 auto ret = ValueType();
21703 JSONSerializer<ValueType>::from_json(*
this, ret);
21737 template <
typename ValueType,
21739 detail::has_non_default_from_json<basic_json_t, ValueType>::value,
21741 ValueType get_impl(detail::priority_tag<1> )
const noexcept(
noexcept(
21742 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
21744 return JSONSerializer<ValueType>::from_json(*
this);
21762 template <
typename BasicJsonType,
21764 detail::is_basic_json<BasicJsonType>::value,
21766 BasicJsonType get_impl(detail::priority_tag<2> )
const
21785 template<
typename BasicJsonType,
21787 std::is_same<BasicJsonType, basic_json_t>::value,
21789 basic_json get_impl(detail::priority_tag<3> )
const
21798 template<
typename PointerType,
21800 std::is_pointer<PointerType>::value,
21802 constexpr auto get_impl(detail::priority_tag<4> )
const noexcept
21803 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
21806 return get_ptr<PointerType>();
21833 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
21834#if defined(JSON_HAS_CPP_14)
21838 noexcept(
std::declval<const basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
21844 static_assert(!std::is_reference<ValueTypeCV>::value,
21845 "get() cannot be used with reference types, you might want to use get_ref()");
21846 return get_impl<ValueType>(detail::priority_tag<4> {});
21876 template<
typename PointerType,
typename std::enable_if<
21877 std::is_pointer<PointerType>::value,
int>::type = 0>
21878 auto get() noexcept -> decltype(
std::declval<basic_json_t&>().template
get_ptr<PointerType>())
21886 template <
typename ValueType,
21891 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
21892 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
21894 JSONSerializer<ValueType>::from_json(*
this, v);
21900 template<
typename ValueType,
21911 typename T, std::size_t N,
21912 typename Array = T (&)[N],
21916 noexcept(
noexcept(JSONSerializer<Array>::from_json(
21917 std::declval<const basic_json_t&>(), v)))
21919 JSONSerializer<Array>::from_json(*
this, v);
21925 template<
typename ReferenceType,
typename std::enable_if<
21926 std::is_reference<ReferenceType>::value,
int>::type = 0>
21930 return get_ref_impl<ReferenceType>(*
this);
21935 template <
typename ReferenceType,
typename std::enable_if <
21936 std::is_reference<ReferenceType>::value&&
21937 std::is_const<typename std::remove_reference<ReferenceType>::type>::value,
int >::type = 0 >
21941 return get_ref_impl<ReferenceType>(*
this);
21973 template <
typename ValueType,
typename std::enable_if <
21981#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
21984#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
21988 >::value,
int >::type = 0 >
22038 return set_parent(
m_data.m_value.array->at(idx));
22061 return m_data.m_value.array->at(idx);
22085 auto it =
m_data.m_value.object->find(
key);
22086 if (it ==
m_data.m_value.object->end())
22090 return set_parent(it->second);
22105 auto it =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22106 if (it ==
m_data.m_value.object->end())
22110 return set_parent(it->second);
22123 auto it =
m_data.m_value.object->find(
key);
22124 if (it ==
m_data.m_value.object->end())
22143 auto it =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22144 if (it ==
m_data.m_value.object->end())
22158 m_data.m_type = value_t::array;
22159 m_data.m_value.array = create<array_t>();
22160 assert_invariant();
22167 if (idx >=
m_data.m_value.array->size())
22169#if JSON_DIAGNOSTICS
22171 const auto old_size =
m_data.m_value.array->size();
22172 const auto old_capacity =
m_data.m_value.array->capacity();
22174 m_data.m_value.array->resize(idx + 1);
22176#if JSON_DIAGNOSTICS
22185 set_parents(
begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
22188 assert_invariant();
22191 return m_data.m_value.array->operator[](idx);
22204 return m_data.m_value.array->operator[](idx);
22217 m_data.m_type = value_t::object;
22218 m_data.m_value.object = create<object_t>();
22219 assert_invariant();
22225 auto result =
m_data.m_value.object->emplace(std::move(
key),
nullptr);
22226 return set_parent(result.first->second);
22239 auto it =
m_data.m_value.object->find(
key);
22249 template<
typename T>
22255 template<
typename T>
22270 m_data.m_type = value_t::object;
22271 m_data.m_value.object = create<object_t>();
22272 assert_invariant();
22278 auto result =
m_data.m_value.object->emplace(std::forward<KeyType>(
key),
nullptr);
22279 return set_parent(result.first->second);
22294 auto it =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22303 template<
typename KeyType>
22305 object_comparator_t,
const typename object_t::key_type&, KeyType >;
22307 template<
typename ValueType>
22308 using value_return_type = std::conditional <
22310 string_t,
typename std::decay<ValueType>::type >;
22318 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22319 ValueType
value(
const typename object_t::key_type&
key,
const ValueType& default_value)
const
22331 return default_value;
22339 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
22343 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22344 ReturnType
value(
const typename object_t::key_type&
key, ValueType && default_value)
const
22356 return std::forward<ValueType>(default_value);
22367 && is_comparable_with_object_key<KeyType>::value
22369 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22370 ValueType
value(KeyType &&
key,
const ValueType& default_value)
const
22376 const auto it =
find(std::forward<KeyType>(
key));
22382 return default_value;
22390 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
22394 && is_comparable_with_object_key<KeyType>::value
22396 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22397 ReturnType
value(KeyType &&
key, ValueType && default_value)
const
22403 const auto it =
find(std::forward<KeyType>(
key));
22409 return std::forward<ValueType>(default_value);
22419 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22433 return default_value;
22442 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
22445 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22459 return std::forward<ValueType>(default_value);
22469 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22471 ValueType
value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, const ValueType& default_value)
const
22473 return value(ptr.convert(), default_value);
22476 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
22480 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
22484 return value(ptr.convert(), std::forward<ValueType>(default_value));
22522 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
22523 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
22532 IteratorType result =
end();
22536 case value_t::boolean:
22537 case value_t::number_float:
22538 case value_t::number_integer:
22539 case value_t::number_unsigned:
22540 case value_t::string:
22541 case value_t::binary:
22550 AllocatorType<string_t> alloc;
22551 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.string);
22552 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.string, 1);
22553 m_data.m_value.string =
nullptr;
22557 AllocatorType<binary_t> alloc;
22558 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.binary);
22559 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.binary, 1);
22560 m_data.m_value.binary =
nullptr;
22563 m_data.m_type = value_t::null;
22564 assert_invariant();
22568 case value_t::object:
22570 result.m_it.object_iterator =
m_data.m_value.object->erase(pos.m_it.object_iterator);
22574 case value_t::array:
22576 result.m_it.array_iterator =
m_data.m_value.array->erase(pos.m_it.array_iterator);
22580 case value_t::null:
22581 case value_t::discarded:
22592 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
22593 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
22594 IteratorType
erase(IteratorType first, IteratorType last)
22602 IteratorType result =
end();
22606 case value_t::boolean:
22607 case value_t::number_float:
22608 case value_t::number_integer:
22609 case value_t::number_unsigned:
22610 case value_t::string:
22611 case value_t::binary:
22614 || !last.m_it.primitive_iterator.is_end()))
22621 AllocatorType<string_t> alloc;
22622 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.string);
22623 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.string, 1);
22624 m_data.m_value.string =
nullptr;
22628 AllocatorType<binary_t> alloc;
22629 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
m_data.m_value.binary);
22630 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_data.m_value.binary, 1);
22631 m_data.m_value.binary =
nullptr;
22634 m_data.m_type = value_t::null;
22635 assert_invariant();
22639 case value_t::object:
22641 result.m_it.object_iterator =
m_data.m_value.object->erase(first.m_it.object_iterator,
22642 last.m_it.object_iterator);
22646 case value_t::array:
22648 result.m_it.array_iterator =
m_data.m_value.array->erase(first.m_it.array_iterator,
22649 last.m_it.array_iterator);
22653 case value_t::null:
22654 case value_t::discarded:
22665 size_type erase_internal(KeyType &&
key)
22673 return m_data.m_value.object->erase(std::forward<KeyType>(
key));
22677 !detail::has_erase_with_key_type<basic_json_t, KeyType>::value,
int > = 0 >
22678 size_type erase_internal(KeyType &&
key)
22686 const auto it = m_data.m_value.object->find(std::forward<KeyType>(
key));
22687 if (it != m_data.m_value.object->end())
22689 m_data.m_value.object->erase(it);
22703 return erase_internal(
key);
22712 return erase_internal(std::forward<KeyType>(
key));
22748 auto result =
end();
22752 result.m_it.object_iterator =
m_data.m_value.object->find(
key);
22762 auto result =
cend();
22766 result.m_it.object_iterator =
m_data.m_value.object->find(
key);
22778 auto result =
end();
22782 result.m_it.object_iterator =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22794 auto result =
cend();
22798 result.m_it.object_iterator =
m_data.m_value.object->find(std::forward<KeyType>(
key));
22842 return ptr.contains(
this);
22845 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22849 return ptr.contains(
this);
22866 result.set_begin();
22882 result.set_begin();
22962 return ref.items();
22973 return ref.items();
22980 return iteration_proxy<iterator>(*
this);
22985 iteration_proxy<const_iterator>
items() const noexcept
22987 return iteration_proxy<const_iterator>(*
this);
23005 case value_t::null:
23011 case value_t::array:
23014 return m_data.m_value.array->empty();
23017 case value_t::object:
23020 return m_data.m_value.object->empty();
23023 case value_t::string:
23024 case value_t::boolean:
23025 case value_t::number_integer:
23026 case value_t::number_unsigned:
23027 case value_t::number_float:
23028 case value_t::binary:
23029 case value_t::discarded:
23044 case value_t::null:
23050 case value_t::array:
23053 return m_data.m_value.array->size();
23056 case value_t::object:
23059 return m_data.m_value.object->size();
23062 case value_t::string:
23063 case value_t::boolean:
23064 case value_t::number_integer:
23065 case value_t::number_unsigned:
23066 case value_t::number_float:
23067 case value_t::binary:
23068 case value_t::discarded:
23083 case value_t::array:
23086 return m_data.m_value.array->max_size();
23089 case value_t::object:
23092 return m_data.m_value.object->max_size();
23095 case value_t::null:
23096 case value_t::string:
23097 case value_t::boolean:
23098 case value_t::number_integer:
23099 case value_t::number_unsigned:
23100 case value_t::number_float:
23101 case value_t::binary:
23102 case value_t::discarded:
23126 case value_t::number_integer:
23128 m_data.m_value.number_integer = 0;
23132 case value_t::number_unsigned:
23134 m_data.m_value.number_unsigned = 0;
23138 case value_t::number_float:
23140 m_data.m_value.number_float = 0.0;
23144 case value_t::boolean:
23146 m_data.m_value.boolean =
false;
23150 case value_t::string:
23152 m_data.m_value.string->clear();
23156 case value_t::binary:
23158 m_data.m_value.binary->clear();
23162 case value_t::array:
23164 m_data.m_value.array->clear();
23168 case value_t::object:
23170 m_data.m_value.object->clear();
23174 case value_t::null:
23175 case value_t::discarded:
23194 m_data.m_type = value_t::array;
23195 m_data.m_value = value_t::array;
23196 assert_invariant();
23200 const auto old_capacity =
m_data.m_value.array->capacity();
23201 m_data.m_value.array->push_back(std::move(val));
23202 set_parent(
m_data.m_value.array->back(), old_capacity);
23227 m_data.m_type = value_t::array;
23228 m_data.m_value = value_t::array;
23229 assert_invariant();
23233 const auto old_capacity =
m_data.m_value.array->capacity();
23234 m_data.m_value.array->push_back(val);
23235 set_parent(
m_data.m_value.array->back(), old_capacity);
23259 m_data.m_type = value_t::object;
23260 m_data.m_value = value_t::object;
23261 assert_invariant();
23265 auto res =
m_data.m_value.object->insert(val);
23266 set_parent(res.first->second);
23281 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
23284 push_back(
typename object_t::value_type(
23285 std::move(
key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
23303 template<
class... Args>
23315 m_data.m_type = value_t::array;
23316 m_data.m_value = value_t::array;
23317 assert_invariant();
23321 const auto old_capacity =
m_data.m_value.array->capacity();
23322 m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
23323 return set_parent(
m_data.m_value.array->back(), old_capacity);
23328 template<
class... Args>
23340 m_data.m_type = value_t::object;
23341 m_data.m_value = value_t::object;
23342 assert_invariant();
23346 auto res =
m_data.m_value.object->emplace(std::forward<Args>(args)...);
23347 set_parent(res.first->second);
23351 it.m_it.object_iterator = res.first;
23354 return {it, res.second};
23360 template<
typename... Args>
23366 auto insert_pos = std::distance(
m_data.m_value.array->begin(), pos.m_it.array_iterator);
23367 m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
23368 result.m_it.array_iterator =
m_data.m_value.array->begin() + insert_pos;
23402 return insert(pos, val);
23453 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
23498 m_data.m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
23516 m_data.m_type = value_t::object;
23517 m_data.m_value.object = create<object_t>();
23518 assert_invariant();
23538 for (
auto it = first; it != last; ++it)
23540 if (merge_objects && it.value().is_object())
23542 auto it2 =
m_data.m_value.object->find(it.key());
23543 if (it2 !=
m_data.m_value.object->end())
23545 it2->second.update(it.value(),
true);
23549 m_data.m_value.object->operator[](it.key()) = it.value();
23550#if JSON_DIAGNOSTICS
23551 m_data.m_value.object->operator[](it.key()).m_parent =
this;
23559 std::is_nothrow_move_constructible<value_t>::value&&
23560 std::is_nothrow_move_assignable<value_t>::value&&
23561 std::is_nothrow_move_constructible<json_value>::value&&
23562 std::is_nothrow_move_assignable<json_value>::value
23569 other.set_parents();
23570 assert_invariant();
23576 std::is_nothrow_move_constructible<value_t>::value&&
23577 std::is_nothrow_move_assignable<value_t>::value&&
23578 std::is_nothrow_move_constructible<json_value>::value&&
23579 std::is_nothrow_move_assignable<json_value>::value
23651 void swap(
typename binary_t::container_type& other)
23676#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
23677 const auto lhs_type = lhs.type(); \
23678 const auto rhs_type = rhs.type(); \
23680 if (lhs_type == rhs_type) \
23682 switch (lhs_type) \
23684 case value_t::array: \
23685 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
23687 case value_t::object: \
23688 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
23690 case value_t::null: \
23691 return (null_result); \
23693 case value_t::string: \
23694 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \
23696 case value_t::boolean: \
23697 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \
23699 case value_t::number_integer: \
23700 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \
23702 case value_t::number_unsigned: \
23703 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \
23705 case value_t::number_float: \
23706 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \
23708 case value_t::binary: \
23709 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
23711 case value_t::discarded: \
23713 return (unordered_result); \
23716 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
23718 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \
23720 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
23722 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \
23724 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
23726 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \
23728 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
23730 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \
23732 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
23734 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \
23736 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
23738 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \
23740 else if(compares_unordered(lhs, rhs))\
23742 return (unordered_result);\
23745 return (default_result);
23756 || (
rhs.is_number_float() && std::isnan(
rhs.m_data.m_value.number_float) && lhs.
is_number()))
23760#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23769 bool compares_unordered(const_reference rhs,
bool inverse =
false) const noexcept
23771 return compares_unordered(*
this, rhs, inverse);
23775#if JSON_HAS_THREE_WAY_COMPARISON
23778 bool operator==(const_reference rhs)
const noexcept
23781#pragma GCC diagnostic push
23782#pragma GCC diagnostic ignored "-Wfloat-equal"
23784 const_reference lhs = *
this;
23787#pragma GCC diagnostic pop
23793 template<
typename ScalarType>
23794 requires std::is_scalar_v<ScalarType>
23795 bool operator==(ScalarType rhs)
const noexcept
23797 return *
this == basic_json(rhs);
23802 bool operator!=(const_reference rhs)
const noexcept
23804 if (compares_unordered(rhs,
true))
23813 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
23815 const_reference lhs = *
this;
23819 std::partial_ordering::equivalent,
23820 std::partial_ordering::unordered,
23821 lhs_type <=> rhs_type)
23826 template<
typename ScalarType>
23827 requires std::is_scalar_v<ScalarType>
23828 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
23830 return *this <=> basic_json(rhs);
23833#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23840 bool operator<=(const_reference rhs)
const noexcept
23842 if (compares_unordered(rhs,
true))
23846 return !(rhs < *
this);
23851 template<
typename ScalarType>
23852 requires std::is_scalar_v<ScalarType>
23853 bool operator<=(ScalarType rhs)
const noexcept
23855 return *
this <= basic_json(rhs);
23861 bool operator>=(const_reference rhs)
const noexcept
23863 if (compares_unordered(rhs,
true))
23867 return !(*
this < rhs);
23872 template<
typename ScalarType>
23873 requires std::is_scalar_v<ScalarType>
23874 bool operator>=(ScalarType rhs)
const noexcept
23876 return *
this >= basic_json(rhs);
23882 friend bool operator==(const_reference lhs, const_reference rhs)
noexcept
23885#pragma GCC diagnostic push
23886#pragma GCC diagnostic ignored "-Wfloat-equal"
23890#pragma GCC diagnostic pop
23896 template<
typename ScalarType,
typename std::enable_if<
23897 std::is_scalar<ScalarType>::value,
int>::type = 0>
23898 friend bool operator==(const_reference lhs, ScalarType rhs)
noexcept
23900 return lhs == basic_json(rhs);
23905 template<
typename ScalarType,
typename std::enable_if<
23906 std::is_scalar<ScalarType>::value,
int>::type = 0>
23907 friend bool operator==(ScalarType lhs, const_reference rhs)
noexcept
23909 return basic_json(lhs) == rhs;
23914 friend bool operator!=(const_reference lhs, const_reference rhs)
noexcept
23916 if (compares_unordered(lhs, rhs,
true))
23920 return !(lhs == rhs);
23925 template<
typename ScalarType,
typename std::enable_if<
23926 std::is_scalar<ScalarType>::value,
int>::type = 0>
23927 friend bool operator!=(const_reference lhs, ScalarType rhs)
noexcept
23929 return lhs != basic_json(rhs);
23934 template<
typename ScalarType,
typename std::enable_if<
23935 std::is_scalar<ScalarType>::value,
int>::type = 0>
23936 friend bool operator!=(ScalarType lhs, const_reference rhs)
noexcept
23938 return basic_json(lhs) != rhs;
23943 friend bool operator<(const_reference lhs, const_reference rhs)
noexcept
23953 template<
typename ScalarType,
typename std::enable_if<
23954 std::is_scalar<ScalarType>::value,
int>::type = 0>
23955 friend bool operator<(const_reference lhs, ScalarType rhs)
noexcept
23957 return lhs < basic_json(rhs);
23962 template<
typename ScalarType,
typename std::enable_if<
23963 std::is_scalar<ScalarType>::value,
int>::type = 0>
23964 friend bool operator<(ScalarType lhs, const_reference rhs)
noexcept
23966 return basic_json(lhs) < rhs;
23971 friend bool operator<=(const_reference lhs, const_reference rhs)
noexcept
23973 if (compares_unordered(lhs, rhs,
true))
23977 return !(rhs < lhs);
23982 template<
typename ScalarType,
typename std::enable_if<
23983 std::is_scalar<ScalarType>::value,
int>::type = 0>
23984 friend bool operator<=(const_reference lhs, ScalarType rhs)
noexcept
23986 return lhs <= basic_json(rhs);
23991 template<
typename ScalarType,
typename std::enable_if<
23992 std::is_scalar<ScalarType>::value,
int>::type = 0>
23993 friend bool operator<=(ScalarType lhs, const_reference rhs)
noexcept
23995 return basic_json(lhs) <= rhs;
24000 friend bool operator>(const_reference lhs, const_reference rhs)
noexcept
24003 if (compares_unordered(lhs, rhs))
24007 return !(lhs <= rhs);
24012 template<
typename ScalarType,
typename std::enable_if<
24013 std::is_scalar<ScalarType>::value,
int>::type = 0>
24014 friend bool operator>(const_reference lhs, ScalarType rhs)
noexcept
24016 return lhs > basic_json(rhs);
24021 template<
typename ScalarType,
typename std::enable_if<
24022 std::is_scalar<ScalarType>::value,
int>::type = 0>
24023 friend bool operator>(ScalarType lhs, const_reference rhs)
noexcept
24025 return basic_json(lhs) > rhs;
24030 friend bool operator>=(const_reference lhs, const_reference rhs)
noexcept
24032 if (compares_unordered(lhs, rhs,
true))
24036 return !(lhs < rhs);
24041 template<
typename ScalarType,
typename std::enable_if<
24042 std::is_scalar<ScalarType>::value,
int>::type = 0>
24043 friend bool operator>=(const_reference lhs, ScalarType rhs)
noexcept
24045 return lhs >= basic_json(rhs);
24050 template<
typename ScalarType,
typename std::enable_if<
24051 std::is_scalar<ScalarType>::value,
int>::type = 0>
24052 friend bool operator>=(ScalarType lhs, const_reference rhs)
noexcept
24054 return basic_json(lhs) >= rhs;
24058#undef JSON_IMPLEMENT_OPERATOR
24071 friend std::ostream& operator<<(std::ostream& o,
const basic_json& j)
24074 const bool pretty_print = o.width() > 0;
24075 const auto indentation = pretty_print ? o.width() : 0;
24081 serializer s(detail::output_adapter<char>(o), o.fill());
24082 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
24093 friend std::ostream& operator>>(
const basic_json& j, std::ostream& o)
24109 template<
typename InputType>
24111 static basic_json parse(InputType&& i,
24112 parser_callback_t cb =
nullptr,
24113 const bool allow_exceptions =
true,
24114 const bool ignore_comments =
false)
24117 parser(
detail::input_adapter(std::forward<InputType>(i)), std::move(cb), allow_exceptions, ignore_comments).parse(
true, result);
24123 template<
typename IteratorType>
24125 static basic_json parse(IteratorType first,
24127 parser_callback_t cb =
nullptr,
24128 const bool allow_exceptions =
true,
24129 const bool ignore_comments =
false)
24132 parser(
detail::input_adapter(std::move(first), std::move(last)), std::move(cb), allow_exceptions, ignore_comments).parse(
true, result);
24138 static basic_json parse(detail::span_input_adapter&& i,
24139 parser_callback_t cb =
nullptr,
24140 const bool allow_exceptions =
true,
24141 const bool ignore_comments =
false)
24144 parser(i.get(), std::move(cb), allow_exceptions, ignore_comments).parse(
true, result);
24150 template<
typename InputType>
24151 static bool accept(InputType&& i,
24152 const bool ignore_comments =
false)
24154 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
24159 template<
typename IteratorType>
24160 static bool accept(IteratorType first, IteratorType last,
24161 const bool ignore_comments =
false)
24163 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
24168 static bool accept(detail::span_input_adapter&& i,
24169 const bool ignore_comments =
false)
24171 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
24176 template <
typename InputType,
typename SAX>
24180 const
bool strict = true,
24181 const
bool ignore_comments = false)
24184 return format == input_format_t::json
24185 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
24191 template<
class IteratorType,
class SAX>
24193 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
24195 const
bool strict = true,
24196 const
bool ignore_comments = false)
24199 return format == input_format_t::json
24200 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
24209 template <
typename SAX>
24214 const
bool strict = true,
24215 const
bool ignore_comments = false)
24218 return format == input_format_t::json
24220 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
24258 case value_t::null:
24260 case value_t::object:
24262 case value_t::array:
24264 case value_t::string:
24266 case value_t::boolean:
24268 case value_t::binary:
24270 case value_t::discarded:
24271 return "discarded";
24272 case value_t::number_integer:
24273 case value_t::number_unsigned:
24274 case value_t::number_float:
24288 value_t m_type = value_t::null;
24301 m_value.array = create<array_t>(cnt, val);
24318#if JSON_DIAGNOSTICS
24323#if JSON_DIAGNOSTIC_POSITIONS
24325 std::size_t start_position = std::string::npos;
24327 std::size_t end_position = std::string::npos;
24329 constexpr std::size_t start_pos() const noexcept
24331 return start_position;
24334 constexpr std::size_t end_pos() const noexcept
24336 return end_position;
24352 std::vector<std::uint8_t> result;
24361 binary_writer<std::uint8_t>(o).write_cbor(j);
24368 binary_writer<char>(o).write_cbor(j);
24375 std::vector<std::uint8_t> result;
24384 binary_writer<std::uint8_t>(o).write_msgpack(j);
24391 binary_writer<char>(o).write_msgpack(j);
24397 const bool use_size =
false,
24398 const bool use_type =
false)
24400 std::vector<std::uint8_t> result;
24401 to_ubjson(j, result, use_size, use_type);
24408 const bool use_size =
false,
const bool use_type =
false)
24410 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
24416 const bool use_size =
false,
const bool use_type =
false)
24418 binary_writer<char>(o).write_ubjson(j, use_size, use_type);
24424 const bool use_size =
false,
24425 const bool use_type =
false,
24428 std::vector<std::uint8_t> result;
24429 to_bjdata(j, result, use_size, use_type, version);
24436 const bool use_size =
false,
const bool use_type =
false,
24439 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type,
true,
true, version);
24445 const bool use_size =
false,
const bool use_type =
false,
24448 binary_writer<char>(o).write_ubjson(j, use_size, use_type,
true,
true, version);
24455 std::vector<std::uint8_t> result;
24464 binary_writer<std::uint8_t>(o).write_bson(j);
24471 binary_writer<char>(o).write_bson(j);
24476 template<
typename InputType>
24479 const bool strict =
true,
24480 const bool allow_exceptions =
true,
24486 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24487 return res ? result :
basic_json(value_t::discarded);
24492 template<
typename IteratorType>
24495 const bool strict =
true,
24496 const bool allow_exceptions =
true,
24502 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24503 return res ? result :
basic_json(value_t::discarded);
24506 template<
typename T>
24510 const
bool strict = true,
24511 const
bool allow_exceptions = true,
24514 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
24520 const
bool strict = true,
24521 const
bool allow_exceptions = true,
24528 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
24529 return res ? result :
basic_json(value_t::discarded);
24534 template<
typename InputType>
24537 const bool strict =
true,
24538 const bool allow_exceptions =
true)
24543 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
24544 return res ? result :
basic_json(value_t::discarded);
24549 template<
typename IteratorType>
24552 const bool strict =
true,
24553 const bool allow_exceptions =
true)
24558 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
24559 return res ? result :
basic_json(value_t::discarded);
24562 template<
typename T>
24566 const
bool strict = true,
24567 const
bool allow_exceptions = true)
24569 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
24575 const
bool strict = true,
24576 const
bool allow_exceptions = true)
24582 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
24583 return res ? result :
basic_json(value_t::discarded);
24588 template<
typename InputType>
24591 const bool strict =
true,
24592 const bool allow_exceptions =
true)
24597 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24598 return res ? result :
basic_json(value_t::discarded);
24603 template<
typename IteratorType>
24606 const bool strict =
true,
24607 const bool allow_exceptions =
true)
24612 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24613 return res ? result :
basic_json(value_t::discarded);
24616 template<
typename T>
24620 const
bool strict = true,
24621 const
bool allow_exceptions = true)
24623 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
24629 const
bool strict = true,
24630 const
bool allow_exceptions = true)
24636 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
24637 return res ? result :
basic_json(value_t::discarded);
24642 template<
typename InputType>
24645 const bool strict =
true,
24646 const bool allow_exceptions =
true)
24651 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
24652 return res ? result :
basic_json(value_t::discarded);
24657 template<
typename IteratorType>
24660 const bool strict =
true,
24661 const bool allow_exceptions =
true)
24666 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
24667 return res ? result :
basic_json(value_t::discarded);
24672 template<
typename InputType>
24675 const bool strict =
true,
24676 const bool allow_exceptions =
true)
24681 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24682 return res ? result :
basic_json(value_t::discarded);
24687 template<
typename IteratorType>
24690 const bool strict =
true,
24691 const bool allow_exceptions =
true)
24696 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24697 return res ? result :
basic_json(value_t::discarded);
24700 template<
typename T>
24704 const
bool strict = true,
24705 const
bool allow_exceptions = true)
24707 return from_bson(ptr, ptr + len, strict, allow_exceptions);
24713 const
bool strict = true,
24714 const
bool allow_exceptions = true)
24720 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
24721 return res ? result :
basic_json(value_t::discarded);
24736 return ptr.get_unchecked(
this);
24739 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24743 return ptr.get_unchecked(
this);
24750 return ptr.get_unchecked(
this);
24753 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24757 return ptr.get_unchecked(
this);
24764 return ptr.get_checked(
this);
24767 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24771 return ptr.get_checked(
this);
24778 return ptr.get_checked(
this);
24781 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
24785 return ptr.get_checked(
this);
24793 json_pointer::flatten(
"", *
this, result);
24801 return json_pointer::unflatten(*
this);
24819 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
24821 const auto get_op = [](
const string_t& op)
24825 return patch_operations::add;
24827 if (op ==
"remove")
24829 return patch_operations::remove;
24831 if (op ==
"replace")
24833 return patch_operations::replace;
24837 return patch_operations::move;
24841 return patch_operations::copy;
24845 return patch_operations::test;
24848 return patch_operations::invalid;
24863 if (top_pointer != ptr)
24865 result.
at(top_pointer);
24869 const auto last_path = ptr.
back();
24874 switch (parent.
m_data.m_type)
24876 case value_t::null:
24877 case value_t::object:
24880 parent[last_path] = val;
24884 case value_t::array:
24886 if (last_path ==
"-")
24893 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
24907 case value_t::string:
24908 case value_t::boolean:
24909 case value_t::number_integer:
24910 case value_t::number_unsigned:
24911 case value_t::number_float:
24912 case value_t::binary:
24913 case value_t::discarded:
24920 const auto operation_remove = [
this, & result](
json_pointer & ptr)
24923 const auto last_path = ptr.
back();
24931 auto it = parent.
find(last_path);
24944 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
24955 for (
const auto& val : json_patch)
24958 const auto get_value = [&val](
const string_t& op,
24963 auto it = val.m_data.m_value.object->find(member);
24966 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
24993 const auto op = get_value(
"op",
"op",
true).template
get<string_t>();
24994 const auto path = get_value(op,
"path",
true).template
get<string_t>();
24997 switch (get_op(op))
24999 case patch_operations::add:
25001 operation_add(ptr, get_value(
"add",
"value",
false));
25005 case patch_operations::remove:
25007 operation_remove(ptr);
25011 case patch_operations::replace:
25014 result.
at(ptr) = get_value(
"replace",
"value",
false);
25018 case patch_operations::move:
25020 const auto from_path = get_value(
"move",
"from",
true).template
get<string_t>();
25030 operation_remove(from_ptr);
25031 operation_add(ptr, v);
25035 case patch_operations::copy:
25037 const auto from_path = get_value(
"copy",
"from",
true).template
get<string_t>();
25046 operation_add(ptr, v);
25050 case patch_operations::test:
25052 bool success =
false;
25057 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
25073 case patch_operations::invalid:
25103 if (source == target)
25108 if (source.
type() != target.
type())
25113 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25118 switch (source.
type())
25120 case value_t::array:
25124 while (i < source.
size() && i < target.
size())
25128 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25137 while (i < source.
size())
25141 result.
insert(result.
begin() + end_index,
object(
25144 {
"path", detail::concat<string_t>(path,
'/', detail::to_string<string_t>(i))}
25150 while (i < target.
size())
25156 {
"value", target[i]}
25164 case value_t::object:
25167 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
25172 if (target.
find(it.key()) != target.
end())
25175 auto temp_diff =
diff(it.value(), target[it.key()], path_key);
25176 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
25183 {
"op",
"remove"}, {
"path", path_key}
25189 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
25191 if (source.
find(it.key()) == source.
end())
25197 {
"op",
"add"}, {
"path", path_key},
25198 {
"value", it.value()}
25206 case value_t::null:
25207 case value_t::string:
25208 case value_t::boolean:
25209 case value_t::number_integer:
25210 case value_t::number_unsigned:
25211 case value_t::number_float:
25212 case value_t::binary:
25213 case value_t::discarded:
25219 {
"op",
"replace"}, {
"path", path}, {
"value", target}
25246 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
25248 if (it.value().is_null())
25254 operator[](it.key()).merge_patch(it.value());
25260 *
this = apply_patch;
25283#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25284 inline nlohmann::json
operator ""_json(
const char* s, std::size_t n)
25286 inline nlohmann::json
operator "" _json(
const char* s, std::size_t n)
25289 return nlohmann::json::parse(s, s + n);
25295#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25296 inline nlohmann::json::json_pointer
operator ""_json_pointer(
const char* s, std::size_t n)
25298 inline nlohmann::json::json_pointer
operator "" _json_pointer(
const char* s, std::size_t n)
25301 return nlohmann::json::json_pointer(std::string(s, n));
25320 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
25322 return nlohmann::detail::hash(j);
25328struct less< ::nlohmann::detail::value_t>
25335 ::nlohmann::detail::value_t rhs)
const noexcept
25337#if JSON_HAS_THREE_WAY_COMPARISON
25338 return std::is_lt(lhs <=> rhs);
25340 return ::nlohmann::detail::operator<(lhs, rhs);
25346#ifndef JSON_HAS_CPP_20
25351inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
25352 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
25353 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
25362#if JSON_USE_GLOBAL_UDLS
25363 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
25364 using nlohmann::literals::json_literals::operator
""_json;
25365 using nlohmann::literals::json_literals::operator
""_json_pointer;
25367 using nlohmann::literals::json_literals::operator
"" _json;
25368 using nlohmann::literals::json_literals::operator
"" _json_pointer;
25384#if defined(__clang__)
25385 #pragma clang diagnostic pop
25390#undef JSON_INTERNAL_CATCH
25392#undef JSON_PRIVATE_UNLESS_TESTED
25393#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
25394#undef NLOHMANN_BASIC_JSON_TPL
25395#undef JSON_EXPLICIT
25396#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
25397#undef JSON_INLINE_VARIABLE
25398#undef JSON_NO_UNIQUE_ADDRESS
25399#undef JSON_DISABLE_ENUM_SERIALIZATION
25400#undef JSON_USE_GLOBAL_UDLS
25402#ifndef JSON_TEST_KEEP_MACROS
25405 #undef JSON_HAS_CPP_11
25406 #undef JSON_HAS_CPP_14
25407 #undef JSON_HAS_CPP_17
25408 #undef JSON_HAS_CPP_20
25409 #undef JSON_HAS_CPP_23
25410 #undef JSON_HAS_FILESYSTEM
25411 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
25412 #undef JSON_HAS_THREE_WAY_COMPARISON
25413 #undef JSON_HAS_RANGES
25414 #undef JSON_HAS_STATIC_RTTI
25415 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
25429#undef JSON_HEDLEY_ALWAYS_INLINE
25430#undef JSON_HEDLEY_ARM_VERSION
25431#undef JSON_HEDLEY_ARM_VERSION_CHECK
25432#undef JSON_HEDLEY_ARRAY_PARAM
25433#undef JSON_HEDLEY_ASSUME
25434#undef JSON_HEDLEY_BEGIN_C_DECLS
25435#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
25436#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
25437#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
25438#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
25439#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
25440#undef JSON_HEDLEY_CLANG_HAS_FEATURE
25441#undef JSON_HEDLEY_CLANG_HAS_WARNING
25442#undef JSON_HEDLEY_COMPCERT_VERSION
25443#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
25444#undef JSON_HEDLEY_CONCAT
25445#undef JSON_HEDLEY_CONCAT3
25446#undef JSON_HEDLEY_CONCAT3_EX
25447#undef JSON_HEDLEY_CONCAT_EX
25448#undef JSON_HEDLEY_CONST
25449#undef JSON_HEDLEY_CONSTEXPR
25450#undef JSON_HEDLEY_CONST_CAST
25451#undef JSON_HEDLEY_CPP_CAST
25452#undef JSON_HEDLEY_CRAY_VERSION
25453#undef JSON_HEDLEY_CRAY_VERSION_CHECK
25454#undef JSON_HEDLEY_C_DECL
25455#undef JSON_HEDLEY_DEPRECATED
25456#undef JSON_HEDLEY_DEPRECATED_FOR
25457#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
25458#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
25459#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
25460#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
25461#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
25462#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
25463#undef JSON_HEDLEY_DIAGNOSTIC_POP
25464#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
25465#undef JSON_HEDLEY_DMC_VERSION
25466#undef JSON_HEDLEY_DMC_VERSION_CHECK
25467#undef JSON_HEDLEY_EMPTY_BASES
25468#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
25469#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
25470#undef JSON_HEDLEY_END_C_DECLS
25471#undef JSON_HEDLEY_FLAGS
25472#undef JSON_HEDLEY_FLAGS_CAST
25473#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
25474#undef JSON_HEDLEY_GCC_HAS_BUILTIN
25475#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
25476#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
25477#undef JSON_HEDLEY_GCC_HAS_EXTENSION
25478#undef JSON_HEDLEY_GCC_HAS_FEATURE
25479#undef JSON_HEDLEY_GCC_HAS_WARNING
25480#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
25481#undef JSON_HEDLEY_GCC_VERSION
25482#undef JSON_HEDLEY_GCC_VERSION_CHECK
25483#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
25484#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
25485#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
25486#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
25487#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
25488#undef JSON_HEDLEY_GNUC_HAS_FEATURE
25489#undef JSON_HEDLEY_GNUC_HAS_WARNING
25490#undef JSON_HEDLEY_GNUC_VERSION
25491#undef JSON_HEDLEY_GNUC_VERSION_CHECK
25492#undef JSON_HEDLEY_HAS_ATTRIBUTE
25493#undef JSON_HEDLEY_HAS_BUILTIN
25494#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
25495#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
25496#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
25497#undef JSON_HEDLEY_HAS_EXTENSION
25498#undef JSON_HEDLEY_HAS_FEATURE
25499#undef JSON_HEDLEY_HAS_WARNING
25500#undef JSON_HEDLEY_IAR_VERSION
25501#undef JSON_HEDLEY_IAR_VERSION_CHECK
25502#undef JSON_HEDLEY_IBM_VERSION
25503#undef JSON_HEDLEY_IBM_VERSION_CHECK
25504#undef JSON_HEDLEY_IMPORT
25505#undef JSON_HEDLEY_INLINE
25506#undef JSON_HEDLEY_INTEL_CL_VERSION
25507#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
25508#undef JSON_HEDLEY_INTEL_VERSION
25509#undef JSON_HEDLEY_INTEL_VERSION_CHECK
25510#undef JSON_HEDLEY_IS_CONSTANT
25511#undef JSON_HEDLEY_IS_CONSTEXPR_
25512#undef JSON_HEDLEY_LIKELY
25513#undef JSON_HEDLEY_MALLOC
25514#undef JSON_HEDLEY_MCST_LCC_VERSION
25515#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
25516#undef JSON_HEDLEY_MESSAGE
25517#undef JSON_HEDLEY_MSVC_VERSION
25518#undef JSON_HEDLEY_MSVC_VERSION_CHECK
25519#undef JSON_HEDLEY_NEVER_INLINE
25520#undef JSON_HEDLEY_NON_NULL
25521#undef JSON_HEDLEY_NO_ESCAPE
25522#undef JSON_HEDLEY_NO_RETURN
25523#undef JSON_HEDLEY_NO_THROW
25524#undef JSON_HEDLEY_NULL
25525#undef JSON_HEDLEY_PELLES_VERSION
25526#undef JSON_HEDLEY_PELLES_VERSION_CHECK
25527#undef JSON_HEDLEY_PGI_VERSION
25528#undef JSON_HEDLEY_PGI_VERSION_CHECK
25529#undef JSON_HEDLEY_PREDICT
25530#undef JSON_HEDLEY_PRINTF_FORMAT
25531#undef JSON_HEDLEY_PRIVATE
25532#undef JSON_HEDLEY_PUBLIC
25533#undef JSON_HEDLEY_PURE
25534#undef JSON_HEDLEY_REINTERPRET_CAST
25535#undef JSON_HEDLEY_REQUIRE
25536#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
25537#undef JSON_HEDLEY_REQUIRE_MSG
25538#undef JSON_HEDLEY_RESTRICT
25539#undef JSON_HEDLEY_RETURNS_NON_NULL
25540#undef JSON_HEDLEY_SENTINEL
25541#undef JSON_HEDLEY_STATIC_ASSERT
25542#undef JSON_HEDLEY_STATIC_CAST
25543#undef JSON_HEDLEY_STRINGIFY
25544#undef JSON_HEDLEY_STRINGIFY_EX
25545#undef JSON_HEDLEY_SUNPRO_VERSION
25546#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
25547#undef JSON_HEDLEY_TINYC_VERSION
25548#undef JSON_HEDLEY_TINYC_VERSION_CHECK
25549#undef JSON_HEDLEY_TI_ARMCL_VERSION
25550#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
25551#undef JSON_HEDLEY_TI_CL2000_VERSION
25552#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
25553#undef JSON_HEDLEY_TI_CL430_VERSION
25554#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
25555#undef JSON_HEDLEY_TI_CL6X_VERSION
25556#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
25557#undef JSON_HEDLEY_TI_CL7X_VERSION
25558#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
25559#undef JSON_HEDLEY_TI_CLPRU_VERSION
25560#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
25561#undef JSON_HEDLEY_TI_VERSION
25562#undef JSON_HEDLEY_TI_VERSION_CHECK
25563#undef JSON_HEDLEY_UNAVAILABLE
25564#undef JSON_HEDLEY_UNLIKELY
25565#undef JSON_HEDLEY_UNPREDICTABLE
25566#undef JSON_HEDLEY_UNREACHABLE
25567#undef JSON_HEDLEY_UNREACHABLE_RETURN
25568#undef JSON_HEDLEY_VERSION
25569#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
25570#undef JSON_HEDLEY_VERSION_DECODE_MINOR
25571#undef JSON_HEDLEY_VERSION_DECODE_REVISION
25572#undef JSON_HEDLEY_VERSION_ENCODE
25573#undef JSON_HEDLEY_WARNING
25574#undef JSON_HEDLEY_WARN_UNUSED_RESULT
25575#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
25576#undef JSON_HEDLEY_FALL_THROUGH
namespace for Niels Lohmann
Definition json.hpp:20166
constexpr bool is_string() const noexcept
Definition json.hpp:21464
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition json.hpp:22699
detail::cbor_tag_handler_t cbor_tag_handler_t
Definition json.hpp:20239
reference operator[](KeyType &&key)
access specified object element
Definition json.hpp:22265
size_type size() const noexcept
Definition json.hpp:23040
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition json.hpp:24494
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
Definition json.hpp:21837
const_iterator end() const noexcept
returns an iterator to one past the last element
Definition json.hpp:22897
reference back()
access the last element
Definition json.hpp:22503
basic_json value_type
Definition json.hpp:20276
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
Definition json.hpp:20904
detail::parse_error parse_error
Definition json.hpp:20258
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
Definition json.hpp:22913
detail::input_format_t input_format_t
Definition json.hpp:20245
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
Definition json.hpp:25086
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
Definition json.hpp:24254
const_reference front() const
access the first element
Definition json.hpp:22496
constexpr bool is_array() const noexcept
Definition json.hpp:21457
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
Definition json.hpp:23558
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition json.hpp:22446
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
Definition json.hpp:22816
iter_impl< const basic_json > const_iterator
Definition json.hpp:20299
constexpr bool is_number_integer() const noexcept
Definition json.hpp:21429
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
Definition json.hpp:20303
data(size_type cnt, const basic_json &val)
Definition json.hpp:24298
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition json.hpp:24689
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition json.hpp:24734
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
Definition json.hpp:20294
std::size_t size_type
Definition json.hpp:20286
detail::type_error type_error
Definition json.hpp:20260
constexpr bool is_structured() const noexcept
return whether type is structured
Definition json.hpp:21401
const_reference operator[](KeyType &&key) const
access specified object element
Definition json.hpp:22289
detail::error_handler_t error_handler_t
Definition json.hpp:20237
const value_type & const_reference
Definition json.hpp:20281
detail::invalid_iterator invalid_iterator
Definition json.hpp:20259
void swap(binary_t &other)
exchanges the values
Definition json.hpp:23635
ReferenceType get_ref()
Definition json.hpp:21927
size_type max_size() const noexcept
returns the maximum possible number of elements
Definition json.hpp:23079
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition json.hpp:23504
ReferenceType get_ref() const
get a reference value (implicit)
Definition json.hpp:21938
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition json.hpp:21478
JSON_PRIVATE_UNLESS_TESTED const_reference rhs
Definition json.hpp:23753
reference operator+=(initializer_list_t init)
add an object to an object
Definition json.hpp:23295
void push_back(basic_json &&val)
add an object to an array
Definition json.hpp:23183
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
Definition json.hpp:22234
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
Definition json.hpp:22985
const_reference back() const
access the last element
Definition json.hpp:22512
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition json.hpp:22594
reference operator+=(const basic_json &val)
add an object to an array
Definition json.hpp:23240
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition json.hpp:23575
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition json.hpp:24590
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition json.hpp:21046
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
Definition json.hpp:23407
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
Definition json.hpp:24674
static allocator_type get_allocator()
returns the allocator associated with the container
Definition json.hpp:20309
nlohmann::byte_container_with_subtype< std::vector< std::uint8_t > > binary_t
Definition json.hpp:20434
reference at(KeyType &&key)
access specified object element with bounds checking
Definition json.hpp:22097
iterator end() noexcept
Definition json.hpp:22888
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition json.hpp:21436
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition json.hpp:23511
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
Definition json.hpp:24453
detail::exception exception
Definition json.hpp:20257
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
Definition json.hpp:22920
data m_data
Definition json.hpp:24316
void push_back(initializer_list_t init)
add an object to an object
Definition json.hpp:23279
detail::parser_callback_t< basic_json > parser_callback_t
Definition json.hpp:20871
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition json.hpp:21087
ValueType & get_to(ValueType &v) const
Definition json.hpp:21904
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
Definition json.hpp:24389
iterator begin() noexcept
Definition json.hpp:22863
detail::parse_event_t parse_event_t
Definition json.hpp:20867
JSON_PRIVATE_UNLESS_TESTED const_reference bool inverse
Definition json.hpp:23753
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
Definition json.hpp:22344
const_iterator cend() const noexcept
Definition json.hpp:22904
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition json.hpp:24644
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition json.hpp:24776
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
Definition json.hpp:21057
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition json.hpp:20892
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition json.hpp:24478
basic_json flatten() const
return flattened JSON value
Definition json.hpp:24790
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition json.hpp:24605
size_type erase(KeyType &&key)
remove element from a JSON object given a key
Definition json.hpp:22710
std::vector< basic_json, std::allocator< basic_json > > array_t
Definition json.hpp:20410
nlohmann::ordered_map< std::string, basic_json, default_object_comparator_t, std::allocator< std::pair< const std::string, basic_json > > > object_t
Definition json.hpp:20402
const binary_t & get_binary() const
get a binary value
Definition json.hpp:22009
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
Definition json.hpp:23427
void patch_inplace(const basic_json &json_patch)
applies a JSON patch in-place without copying the object
Definition json.hpp:24815
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
Definition json.hpp:22397
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition json.hpp:24748
value_type & reference
Definition json.hpp:20279
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
Definition json.hpp:20243
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
Definition json.hpp:22833
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
Definition json.hpp:24359
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
Definition json.hpp:24469
iterator find(const typename object_t::key_type &key)
Definition json.hpp:22746
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
Definition json.hpp:21035
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
Definition json.hpp:24423
const_reference at(KeyType &&key) const
access specified object element with bounds checking
Definition json.hpp:22135
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
Definition json.hpp:20317
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition json.hpp:21094
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
Definition json.hpp:22760
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
Definition json.hpp:24350
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition json.hpp:22524
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
Definition json.hpp:23380
double number_float_t
Definition json.hpp:20430
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
Definition json.hpp:22319
std::allocator< basic_json > allocator_type
Definition json.hpp:20289
typename std::allocator_traits< allocator_type >::pointer pointer
Definition json.hpp:20292
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
Definition json.hpp:21365
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
Definition json.hpp:25238
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
Definition json.hpp:21891
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
Definition json.hpp:24435
reference operator[](T *key)
Definition json.hpp:22250
reference at(size_type idx)
access specified array element with bounds checking
Definition json.hpp:22031
iterator find(KeyType &&key)
find an element in a JSON object
Definition json.hpp:22776
constexpr bool is_number_float() const noexcept
Definition json.hpp:21443
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
Definition json.hpp:22927
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.hpp:24396
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
Definition json.hpp:24762
bool boolean_t
Definition json.hpp:20418
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const string_t &path="")
creates a diff as a JSON patch
Definition json.hpp:25096
detail::value_t value_t
Definition json.hpp:20231
std::less< std::string > default_object_comparator_t
Definition json.hpp:20397
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition json.hpp:23271
const_iterator cbegin() const noexcept
Definition json.hpp:22879
reference operator[](typename object_t::key_type key)
access specified object element
Definition json.hpp:22212
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition json.hpp:21649
~basic_json() noexcept
destructor
Definition json.hpp:21347
detail::out_of_range out_of_range
Definition json.hpp:20261
const_reverse_iterator crend() const noexcept
Definition json.hpp:22948
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
Definition json.hpp:20976
void swap(typename binary_t::container_type &other)
exchanges the values
Definition json.hpp:23651
binary_t & get_binary()
get a binary value
Definition json.hpp:21997
const_iterator begin() const noexcept
returns an iterator to the first element
Definition json.hpp:22872
constexpr bool is_number() const noexcept
Definition json.hpp:21422
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
Definition json.hpp:23478
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition json.hpp:24536
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition json.hpp:21878
const_reference operator[](T *key) const
Definition json.hpp:22256
data(const value_t v)
Definition json.hpp:24293
reference operator[](size_type idx)
access specified array element
Definition json.hpp:22153
basic_json(const JsonRef &ref)
Definition json.hpp:21215
adl_serializer< T, SFINAE > json_serializer
Definition json.hpp:20235
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value &&std::is_nothrow_move_assignable< json_base_class_t >::value)
copy assignment
Definition json.hpp:21318
static iteration_proxy< iterator > iterator_wrapper(reference ref) noexcept
Definition json.hpp:22960
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.hpp:24415
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
Definition json.hpp:21915
std::int64_t number_integer_t
Definition json.hpp:20422
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition json.hpp:21638
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition json.hpp:22115
constexpr bool is_binary() const noexcept
Definition json.hpp:21471
void swap(object_t &other)
exchanges the values
Definition json.hpp:23603
basic_json unflatten() const
unflatten a previously flattened JSON value
Definition json.hpp:24799
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
Definition json.hpp:23458
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false, const bjdata_version_t version=bjdata_version_t::draft2)
create a BJData serialization of a given JSON value
Definition json.hpp:24444
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition json.hpp:21068
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
Definition json.hpp:22978
bool empty() const noexcept
checks whether the container is empty.
Definition json.hpp:23001
void swap(array_t &other)
exchanges the values
Definition json.hpp:23587
void erase(const size_type idx)
remove element from a JSON array given an index
Definition json.hpp:22717
reference operator+=(basic_json &&val)
add an object to an array
Definition json.hpp:23208
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
Definition json.hpp:22840
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition json.hpp:21387
reference emplace_back(Args &&... args)
add an object to an array
Definition json.hpp:23304
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition json.hpp:22420
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition json.hpp:21079
detail::bjdata_version_t bjdata_version_t
Definition json.hpp:20241
std::string string_t
Definition json.hpp:20414
friend class ::nlohmann::detail::parser
Definition json.hpp:20176
void push_back(const basic_json &val)
add an object to an array
Definition json.hpp:23216
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
Definition json.hpp:22370
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition json.hpp:22077
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
Definition json.hpp:24659
json_value m_value
Definition json.hpp:24291
const_reverse_iterator crbegin() const noexcept
Definition json.hpp:22941
json_sax< basic_json > json_sax_t
Definition json.hpp:20247
constexpr bool is_boolean() const noexcept
Definition json.hpp:21415
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
Definition json.hpp:22806
reference front()
access the first element
Definition json.hpp:22489
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition json.hpp:21394
constexpr bool is_null() const noexcept
Definition json.hpp:21408
void clear() noexcept
clears the contents
Definition json.hpp:23122
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition json.hpp:24407
detail::other_error other_error
Definition json.hpp:20262
JSON_PRIVATE_UNLESS_TESTED const_reference bool static SAX bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
Definition json.hpp:24178
basic_json(basic_json &&other) noexcept
move constructor
Definition json.hpp:21292
iter_impl< basic_json > iterator
Definition json.hpp:20297
basic_json(const value_t v)
create an empty value with a given type
Definition json.hpp:20884
const_reference operator[](size_type idx) const
access specified array element
Definition json.hpp:22199
std::ptrdiff_t difference_type
Definition json.hpp:20284
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
Definition json.hpp:23400
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
Definition json.hpp:22934
std::uint64_t number_unsigned_t
Definition json.hpp:20426
friend std::istream & operator>>(std::istream &i, basic_json &j)
Definition json.hpp:24239
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
Definition json.hpp:24373
void swap(string_t &other)
exchanges the values
Definition json.hpp:23619
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
Definition json.hpp:20918
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
Definition json.hpp:20301
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition json.hpp:22054
detail::actual_object_comparator_t< basic_json > object_comparator_t
Definition json.hpp:20438
basic_json(const basic_json &other)
copy constructor
Definition json.hpp:21219
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition json.hpp:23248
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
Definition json.hpp:23329
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
Definition json.hpp:24366
constexpr bool is_object() const noexcept
Definition json.hpp:21450
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
Definition json.hpp:24382
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition json.hpp:24551
iterator insert_iterator(const_iterator pos, Args &&... args)
Definition json.hpp:23361
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition json.hpp:21106
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
Definition json.hpp:22824
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
Definition json.hpp:24462
const_iterator find(KeyType &&key) const
find an element in a JSON object
Definition json.hpp:22792
::nlohmann::json_pointer< std::string > json_pointer
Definition json.hpp:20233
bool operator!=(const byte_container_with_subtype &rhs) const
Definition json.hpp:6273
byte_container_with_subtype() noexcept(noexcept(container_type()))
Definition json.hpp:6239
std::uint64_t subtype_type
Definition json.hpp:6236
bool operator==(const byte_container_with_subtype &rhs) const
Definition json.hpp:6267
BinaryType container_type
Definition json.hpp:6235
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
Definition json.hpp:6261
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
Definition json.hpp:6249
constexpr subtype_type subtype() const noexcept
return the binary subtype
Definition json.hpp:6288
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
Definition json.hpp:6254
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
Definition json.hpp:6295
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
Definition json.hpp:6244
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
Definition json.hpp:6280
void clear_subtype() noexcept
clears the binary subtype
Definition json.hpp:6302
deserialization of CBOR, MessagePack, and UBJSON values
Definition json.hpp:9885
binary_reader(const binary_reader &)=delete
binary_reader(binary_reader &&)=default
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
Definition json.hpp:9901
binary_reader & operator=(const binary_reader &)=delete
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
Definition json.hpp:9922
binary_reader & operator=(binary_reader &&)=default
void write_bson(const BasicJsonType &j)
Definition json.hpp:15859
static constexpr CharType to_char_type(std::uint8_t x) noexcept
Definition json.hpp:17599
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false, const bjdata_version_t bjdata_version=bjdata_version_t::draft2)
Definition json.hpp:16539
static CharType to_char_type(std::uint8_t x) noexcept
Definition json.hpp:17606
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
Definition json.hpp:15850
static constexpr CharType to_char_type(InputCharType x) noexcept
Definition json.hpp:17628
void write_msgpack(const BasicJsonType &j)
Definition json.hpp:16212
void write_cbor(const BasicJsonType &j)
Definition json.hpp:15888
general exception of the basic_json class
Definition json.hpp:4534
exception(int id_, const char *what_arg)
Definition json.hpp:4547
const int id
the id of the exception
Definition json.hpp:4543
static std::string diagnostics(std::nullptr_t)
Definition json.hpp:4554
static std::string name(const std::string &ename, int id_)
Definition json.hpp:4549
const char * what() const noexcept override
returns the explanatory string
Definition json.hpp:4537
static std::string diagnostics(const BasicJsonType *leaf_element)
Definition json.hpp:4560
exception indicating errors with iterators
Definition json.hpp:4703
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4706
iter_impl operator+(difference_type i) const
add to iterator
Definition json.hpp:14241
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition json.hpp:13795
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition json.hpp:14186
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition json.hpp:13785
bool operator<(const iter_impl &other) const
comparison: smaller
Definition json.hpp:14128
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition json.hpp:14168
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition json.hpp:14232
iter_impl & operator--()
pre-decrement (–it)
Definition json.hpp:14038
const object_t::key_type & key() const
return the key of an object iterator
Definition json.hpp:14341
bool operator==(const IterImpl &other) const
comparison: equal
Definition json.hpp:14079
iter_impl operator++(int) &
post-increment (it++)
Definition json.hpp:13976
iter_impl & operator+=(difference_type i)
add to iterator
Definition json.hpp:14195
reference operator[](difference_type n) const
access to successor
Definition json.hpp:14303
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
Definition json.hpp:13690
typename BasicJsonType::difference_type difference_type
Definition json.hpp:13688
pointer operator->() const
dereference the iterator
Definition json.hpp:13934
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
Definition json.hpp:14366
difference_type operator-(const iter_impl &other) const
return difference
Definition json.hpp:14274
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
Definition json.hpp:13683
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition json.hpp:14252
reference value() const
return the value of an iterator
Definition json.hpp:14357
bool operator>(const iter_impl &other) const
comparison: greater than
Definition json.hpp:14177
iter_impl & operator++()
pre-increment (++it)
Definition json.hpp:13987
typename BasicJsonType::value_type value_type
Definition json.hpp:13686
reference operator*() const
return a reference to the value pointed to by the iterator
Definition json.hpp:13890
iter_impl operator-(difference_type i) const
subtract from iterator
Definition json.hpp:14263
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
Definition json.hpp:13694
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
Definition json.hpp:13770
bool operator!=(const IterImpl &other) const
comparison: not equal
Definition json.hpp:14119
iter_impl operator--(int) &
post-decrement (it–)
Definition json.hpp:14027
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
Definition json.hpp:13760
void set_end() noexcept
set the iterator past the last value
Definition json.hpp:13851
iteration_proxy_value operator++(int) &
Definition json.hpp:5551
iteration_proxy_value(iteration_proxy_value const &)=default
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
Definition json.hpp:5560
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
Definition json.hpp:5566
std::ptrdiff_t difference_type
Definition json.hpp:5497
value_type & reference
Definition json.hpp:5500
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
Definition json.hpp:5518
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
Definition json.hpp:5543
iteration_proxy_value()=default
std::forward_iterator_tag iterator_category
Definition json.hpp:5501
iteration_proxy_value value_type
Definition json.hpp:5498
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
IteratorType::reference value() const
return value of the iterator
Definition json.hpp:5608
value_type * pointer
Definition json.hpp:5499
const string_type & key() const
return key of the iterator
Definition json.hpp:5572
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
Definition json.hpp:5502
proxy class for the items() function
Definition json.hpp:5616
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
Definition json.hpp:5641
iteration_proxy(iteration_proxy const &)=default
iteration_proxy()=default
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy_value< IteratorType > begin() const noexcept
return iterator begin (needed for range-based for)
Definition json.hpp:5635
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
Definition json.hpp:5625
iteration_proxy & operator=(iteration_proxy const &)=default
Definition json.hpp:15571
json_ref(json_ref &&) noexcept=default
json_ref(const value_type &value)
Definition json.hpp:15579
json_ref(value_type &&value)
Definition json.hpp:15575
value_type const & operator*() const
Definition json.hpp:15610
value_type const * operator->() const
Definition json.hpp:15615
json_ref(std::initializer_list< json_ref > init)
Definition json.hpp:15583
json_ref(Args &&... args)
Definition json.hpp:15590
value_type moved_or_copied() const
Definition json.hpp:15601
BasicJsonType value_type
Definition json.hpp:15573
json_reverse_iterator operator++(int) &
post-increment (it++)
Definition json.hpp:14436
json_reverse_iterator operator--(int) &
post-decrement (it–)
Definition json.hpp:14448
json_reverse_iterator & operator++()
pre-increment (++it)
Definition json.hpp:14442
std::ptrdiff_t difference_type
Definition json.hpp:14422
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition json.hpp:14460
reference operator[](difference_type n) const
access to successor
Definition json.hpp:14484
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
Definition json.hpp:14490
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition json.hpp:14478
typename Base::reference reference
the reference type for the pointed-to element
Definition json.hpp:14426
reference value() const
return the value of an iterator
Definition json.hpp:14497
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition json.hpp:14433
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition json.hpp:14454
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
Definition json.hpp:14424
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition json.hpp:14472
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition json.hpp:14429
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition json.hpp:14466
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:9603
bool end_object()
Definition json.hpp:9653
bool binary(binary_t &)
Definition json.hpp:9638
bool number_integer(number_integer_t)
Definition json.hpp:9618
bool start_array(std::size_t=detail::unknown_size())
Definition json.hpp:9658
bool boolean(bool)
Definition json.hpp:9613
bool null()
Definition json.hpp:9608
bool end_array()
Definition json.hpp:9663
bool number_unsigned(number_unsigned_t)
Definition json.hpp:9623
bool start_object(std::size_t=detail::unknown_size())
Definition json.hpp:9643
bool string(string_t &)
Definition json.hpp:9633
typename BasicJsonType::binary_t binary_t
Definition json.hpp:9606
bool number_float(number_float_t, const string_t &)
Definition json.hpp:9628
bool parse_error(std::size_t, const std::string &, const detail::exception &)
Definition json.hpp:9668
bool key(string_t &)
Definition json.hpp:9648
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:9602
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:9604
typename BasicJsonType::string_t string_t
Definition json.hpp:9605
bool start_array(std::size_t len)
Definition json.hpp:9331
typename BasicJsonType::parser_callback_t parser_callback_t
Definition json.hpp:9170
bool null()
Definition json.hpp:9190
typename BasicJsonType::parse_event_t parse_event_t
Definition json.hpp:9171
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
bool number_integer(number_integer_t val)
Definition json.hpp:9202
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition json.hpp:9410
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:9167
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
lexer< BasicJsonType, InputAdapterType > lexer_t
Definition json.hpp:9172
bool end_object()
Definition json.hpp:9281
bool number_unsigned(number_unsigned_t val)
Definition json.hpp:9208
bool number_float(number_float_t val, const string_t &)
Definition json.hpp:9214
constexpr bool is_errored() const
Definition json.hpp:9422
json_sax_dom_callback_parser(BasicJsonType &r, parser_callback_t cb, const bool allow_exceptions_=true, lexer_t *lexer_=nullptr)
Definition json.hpp:9174
bool binary(binary_t &val)
Definition json.hpp:9226
typename BasicJsonType::string_t string_t
Definition json.hpp:9168
bool boolean(bool val)
Definition json.hpp:9196
bool key(string_t &val)
Definition json.hpp:9264
bool string(string_t &val)
Definition json.hpp:9220
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:9166
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:9165
typename BasicJsonType::binary_t binary_t
Definition json.hpp:9169
~json_sax_dom_callback_parser()=default
bool end_array()
Definition json.hpp:9363
bool start_object(std::size_t len)
Definition json.hpp:9232
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
SAX implementation to create a JSON value from SAX events.
Definition json.hpp:8857
bool number_float(number_float_t val, const string_t &)
Definition json.hpp:8906
bool number_unsigned(number_unsigned_t val)
Definition json.hpp:8900
json_sax_dom_parser(const json_sax_dom_parser &)=delete
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool binary(binary_t &val)
Definition json.hpp:8918
typename BasicJsonType::binary_t binary_t
Definition json.hpp:8863
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true, lexer_t *lexer_=nullptr)
Definition json.hpp:8871
bool start_object(std::size_t len)
Definition json.hpp:8924
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:8859
bool key(string_t &val)
Definition json.hpp:8947
bool end_object()
Definition json.hpp:8957
typename BasicJsonType::string_t string_t
Definition json.hpp:8862
~json_sax_dom_parser()=default
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:8860
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition json.hpp:9015
lexer< BasicJsonType, InputAdapterType > lexer_t
Definition json.hpp:8864
bool boolean(bool val)
Definition json.hpp:8888
bool start_array(std::size_t len)
Definition json.hpp:8975
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:8861
bool end_array()
Definition json.hpp:8996
json_sax_dom_parser(json_sax_dom_parser &&)=default
constexpr bool is_errored() const
Definition json.hpp:9027
bool null()
Definition json.hpp:8882
bool string(string_t &val)
Definition json.hpp:8912
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool number_integer(number_integer_t val)
Definition json.hpp:8894
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
Definition json.hpp:7124
token_type
token types for the parser
Definition json.hpp:7101
@ value_float
an floating point number – use get_number_float() for actual value
Definition json.hpp:7109
@ begin_array
the character for array begin [
Definition json.hpp:7110
@ value_string
a string – use get_string() for actual value
Definition json.hpp:7106
@ end_array
the character for array end ]
Definition json.hpp:7112
@ uninitialized
indicating the scanner is uninitialized
Definition json.hpp:7102
@ parse_error
indicating a parse error
Definition json.hpp:7116
@ value_integer
a signed integer – use get_number_integer() for actual value
Definition json.hpp:7108
@ value_separator
the value separator ,
Definition json.hpp:7115
@ end_object
the character for object end }
Definition json.hpp:7113
@ literal_true
the true literal
Definition json.hpp:7103
@ begin_object
the character for object begin {
Definition json.hpp:7111
@ value_unsigned
an unsigned integer – use get_number_unsigned() for actual value
Definition json.hpp:7107
@ literal_null
the null literal
Definition json.hpp:7105
@ end_of_input
indicating the end of the input buffer
Definition json.hpp:7117
@ name_separator
the name separator :
Definition json.hpp:7114
@ literal_or_value
a literal or the begin of a value (only for diagnostics)
Definition json.hpp:7118
@ literal_false
the false literal
Definition json.hpp:7104
lexical analysis
Definition json.hpp:7174
bool skip_bom()
skip the UTF-8 byte order mark
Definition json.hpp:8556
void skip_whitespace()
Definition json.hpp:8570
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
Definition json.hpp:7185
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
Definition json.hpp:8543
std::string get_token_string() const
Definition json.hpp:8518
constexpr number_integer_t get_number_integer() const noexcept
return integer value
Definition json.hpp:8477
constexpr position_t get_position() const noexcept
return position of last read token
Definition json.hpp:8510
token_type scan()
Definition json.hpp:8579
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
Definition json.hpp:8483
typename lexer_base< BasicJsonType >::token_type token_type
Definition json.hpp:7183
lexer & operator=(lexer &&)=default
lexer(const lexer &)=delete
lexer & operator=(lexer &)=delete
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
Definition json.hpp:8495
constexpr number_float_t get_number_float() const noexcept
return floating-point value
Definition json.hpp:8489
exception indicating other library errors
Definition json.hpp:4755
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4758
exception indicating access out of the defined range
Definition json.hpp:4738
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4741
Definition json.hpp:15790
output_adapter(StringType &s)
Definition json.hpp:15801
output_adapter(std::basic_ostream< CharType > &s)
Definition json.hpp:15797
output_adapter(std::vector< CharType, AllocatorType > &vec)
Definition json.hpp:15793
output adapter for output streams
Definition json.hpp:15742
void write_characters(const CharType *s, std::size_t length) override
Definition json.hpp:15754
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
Definition json.hpp:15744
void write_character(CharType c) override
Definition json.hpp:15748
output adapter for basic_string
Definition json.hpp:15767
void write_character(CharType c) override
Definition json.hpp:15773
output_string_adapter(StringType &s) noexcept
Definition json.hpp:15769
void write_characters(const CharType *s, std::size_t length) override
Definition json.hpp:15779
output adapter for byte vectors
Definition json.hpp:15717
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
Definition json.hpp:15719
void write_characters(const CharType *s, std::size_t length) override
Definition json.hpp:15729
void write_character(CharType c) override
Definition json.hpp:15723
exception indicating a parse error
Definition json.hpp:4650
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
Definition json.hpp:4662
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4670
const std::size_t byte
byte index of the parse error
Definition json.hpp:4687
void parse(const bool strict, BasicJsonType &result)
public parser interface
Definition json.hpp:13003
bool accept(const bool strict=true)
public accept interface
Definition json.hpp:13063
parser(InputAdapterType &&adapter, parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
a parser reading from an input adapter
Definition json.hpp:12981
bool sax_parse(SAX *sax, const bool strict=true)
Definition json.hpp:13071
Definition json.hpp:13475
primitive_iterator_t & operator++() noexcept
Definition json.hpp:13537
primitive_iterator_t & operator-=(difference_type n) noexcept
Definition json.hpp:13569
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
Definition json.hpp:13504
primitive_iterator_t & operator--() noexcept
Definition json.hpp:13550
void set_end() noexcept
set iterator to a defined past the end
Definition json.hpp:13498
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition json.hpp:13520
constexpr bool is_end() const noexcept
return whether the iterator is at end
Definition json.hpp:13510
primitive_iterator_t operator++(int) &noexcept
Definition json.hpp:13543
primitive_iterator_t & operator+=(difference_type n) noexcept
Definition json.hpp:13563
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition json.hpp:13515
constexpr difference_type get_value() const noexcept
Definition json.hpp:13486
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition json.hpp:13532
primitive_iterator_t operator+(difference_type n) noexcept
Definition json.hpp:13525
void set_begin() noexcept
set iterator to a defined beginning
Definition json.hpp:13492
primitive_iterator_t operator--(int) &noexcept
Definition json.hpp:13556
std::array< char, 512 > string_buffer
string buffer
Definition json.hpp:19749
std::uint8_t state
Definition json.hpp:19167
std::size_t bytes_after_last_accept
Definition json.hpp:19171
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
Definition json.hpp:18840
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
Definition json.hpp:19165
std::size_t undumped_chars
Definition json.hpp:19172
const char thousands_sep
the locale's thousand separator character
Definition json.hpp:19744
const char decimal_point
the locale's decimal point character
Definition json.hpp:19746
serializer & operator=(const serializer &)=delete
const error_handler_t error_handler
error_handler how to react on decoding errors
Definition json.hpp:19757
string_t indent_string
the indentation string
Definition json.hpp:19754
const std::lconv * loc
the locale
Definition json.hpp:19742
serializer & operator=(serializer &&)=delete
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
Definition json.hpp:19739
const char indent_char
the indentation character
Definition json.hpp:19752
std::size_t bytes
Definition json.hpp:19168
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
Definition json.hpp:18880
serializer(const serializer &)=delete
serializer(serializer &&)=delete
exception indicating executing a member function with a wrong type
Definition json.hpp:4721
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition json.hpp:4724
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
Definition json.hpp:14592
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
Definition json.hpp:14687
typename string_t_helper< RefStringType >::type string_t
Definition json.hpp:14614
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
Definition json.hpp:14694
json_pointer(const string_t &s="")
create JSON pointer
Definition json.hpp:14618
bool empty() const noexcept
return whether pointer points to the root document
Definition json.hpp:14753
void pop_back()
remove last reference token
Definition json.hpp:14715
string_t to_string() const
return a string representation of the JSON pointer
Definition json.hpp:14624
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
Definition json.hpp:14672
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
Definition json.hpp:14746
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
Definition json.hpp:14654
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
Definition json.hpp:14679
json_pointer parent_pointer() const
returns the parent of this JSON pointer
Definition json.hpp:14701
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
Definition json.hpp:14664
friend class json_pointer
Definition json.hpp:14598
const string_t & back() const
return last reference token
Definition json.hpp:14727
friend std::ostream & operator<<(std::ostream &o, const json_pointer &ptr)
write string representation of the JSON pointer to stream
Definition json.hpp:14645
friend class basic_json
Definition json.hpp:14595
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
Definition json.hpp:14739
decltype( get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
Definition json.hpp:5687
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
Definition json.hpp:2616
#define JSON_HEDLEY_CONST
Definition json.hpp:1829
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
Definition json.hpp:1113
#define JSON_INLINE_VARIABLE
Definition json.hpp:2515
#define JSON_HEDLEY_WARN_UNUSED_RESULT
Definition json.hpp:1459
#define JSON_PRIVATE_UNLESS_TESTED
Definition json.hpp:2575
#define NLOHMANN_JSON_VERSION_PATCH
Definition json.hpp:70
#define JSON_HEDLEY_LIKELY(expr)
Definition json.hpp:1724
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.hpp:15487
#define JSON_HEDLEY_NON_NULL(...)
Definition json.hpp:1617
#define JSON_INTERNAL_CATCH(exception)
Definition json.hpp:2542
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition json.hpp:25270
#define JSON_HEDLEY_RETURNS_NON_NULL
Definition json.hpp:2058
#define JSON_CATCH(exception)
Definition json.hpp:2541
#define JSON_ASSERT(x)
Definition json.hpp:2568
#define JSON_THROW(exception)
Definition json.hpp:2539
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
Definition json.hpp:81
#define NLOHMANN_JSON_VERSION_MAJOR
Definition json.hpp:68
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.hpp:15537
#define NLOHMANN_BASIC_JSON_TPL
Definition json.hpp:2626
#define JSON_HEDLEY_UNLIKELY(expr)
Definition json.hpp:1725
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
Definition json.hpp:12860
#define JSON_TRY
Definition json.hpp:2540
#define NLOHMANN_JSON_NAMESPACE_END
Definition json.hpp:155
#define JSON_NO_UNIQUE_ADDRESS
Definition json.hpp:2521
basic_json< nlohmann::ordered_map > ordered_json
specialization that maintains the insertion order of object keys
Definition json.hpp:3557
#define NLOHMANN_JSON_VERSION_MINOR
Definition json.hpp:69
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
Definition json.hpp:2910
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.hpp:15512
#define NLOHMANN_JSON_NAMESPACE_BEGIN
Definition json.hpp:145
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
Definition json.hpp:12857
#define JSON_HEDLEY_DIAGNOSTIC_POP
Definition json.hpp:1114
#define JSON_EXPLICIT
Definition json.hpp:2947
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
Definition json.hpp:1407
#define JSON_HEDLEY_PURE
Definition json.hpp:1798
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
Definition json.hpp:23676
#define JSON_DIAGNOSTIC_POSITIONS
Definition json.hpp:77
implements the Grisu2 algorithm for binary to decimal floating-point conversion.
Definition json.hpp:17717
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
Definition json.hpp:18164
cached_power get_cached_power_for_binary_exponent(int e)
Definition json.hpp:18000
Target reinterpret_bits(const Source source)
Definition json.hpp:17720
boundaries compute_boundaries(FloatType value)
Definition json.hpp:17861
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
Definition json.hpp:18218
constexpr int kAlpha
Definition json.hpp:17983
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
Definition json.hpp:18500
constexpr int kGamma
Definition json.hpp:17984
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
Definition json.hpp:18259
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
Definition json.hpp:18600
JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
Definition json.hpp:18652
constexpr bool is_transparent()
Definition json.hpp:4344
constexpr bool is_c_string()
Definition json.hpp:4316
detail namespace with internal helper functions
Definition json.hpp:260
make_integer_sequence< size_t, N > make_index_sequence
Definition json.hpp:3315
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
Definition json.hpp:4419
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
Definition json.hpp:4226
input_format_t
the supported input formats
Definition json.hpp:6523
@ bson
Definition json.hpp:6523
@ bjdata
Definition json.hpp:6523
@ ubjson
Definition json.hpp:6523
@ json
Definition json.hpp:6523
@ cbor
Definition json.hpp:6523
@ msgpack
Definition json.hpp:6523
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition json.hpp:311
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
Definition json.hpp:6104
decltype(T::to_json(std::declval< Args >()...)) to_json_function
Definition json.hpp:3643
detector< Default, void, Op, Args... > detected_or
Definition json.hpp:314
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
Definition json.hpp:9731
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
Definition json.hpp:4160
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
Definition json.hpp:4440
decltype(std::declval< T & >().end_object()) end_object_function_t
Definition json.hpp:9743
OutStringType concat(Args &&... args)
Definition json.hpp:4499
typename T::value_type value_type_t
Definition json.hpp:3628
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
Definition json.hpp:3346
JSON_HEDLEY_RETURNS_NON_NULL char * to_chars(char *first, const char *last, FloatType value)
generates a decimal representation of the floating-point number value in [first, last).
Definition json.hpp:18737
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
Definition json.hpp:9711
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition json.hpp:320
is_detected< string_can_append, StringType, Arg > detect_string_can_append
Definition json.hpp:4422
typename std::enable_if< B, T >::type enable_if_t
Definition json.hpp:3219
parse_event_t
Definition json.hpp:12945
@ value
the parser finished reading a JSON value
Definition json.hpp:12957
@ key
the parser read a key of a value in an object
Definition json.hpp:12955
@ array_end
the parser read ] and finished processing a JSON array
Definition json.hpp:12953
@ array_start
the parser read [ and started to process a JSON array
Definition json.hpp:12951
@ object_start
the parser read { and started to process a JSON object
Definition json.hpp:12947
@ object_end
the parser read } and finished processing a JSON object
Definition json.hpp:12949
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
Definition json.hpp:4222
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition json.hpp:305
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
Definition json.hpp:4142
typename T::pointer pointer_t
Definition json.hpp:3634
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
Definition json.hpp:5272
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
Definition json.hpp:5077
typename utility_internal::Gen< T, N >::type make_integer_sequence
Definition json.hpp:3307
conjunction< std::is_integral< Types >... > all_integral
Definition json.hpp:4212
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
Definition json.hpp:15712
typename detected_or< Default, Op, Args... >::type detected_or_t
Definition json.hpp:317
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
Definition json.hpp:9739
decltype(std::declval< T & >().null()) null_function_t
Definition json.hpp:9708
void int_to_string(StringType &target, std::size_t value)
Definition json.hpp:5469
T conditional_static_cast(U value)
Definition json.hpp:4200
typename T::difference_type difference_type_t
Definition json.hpp:3631
conjunction< std::is_unsigned< Types >... > all_unsigned
Definition json.hpp:4218
constexpr T static_const< T >::value
Definition json.hpp:3342
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
Definition json.hpp:9735
decltype(std::declval< T & >().number_float( std::declval< Float >(), std::declval< const String & >())) number_float_function_t
Definition json.hpp:9723
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
Definition json.hpp:3095
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
Definition json.hpp:9746
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
Definition json.hpp:4434
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition json.hpp:5651
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
Definition json.hpp:4173
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
Definition json.hpp:3722
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
Definition json.hpp:4169
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
Definition json.hpp:6977
bool little_endianness(int num=1) noexcept
determine system byte order
Definition json.hpp:9871
cbor_tag_handler_t
how to treat CBOR tags
Definition json.hpp:9858
@ ignore
ignore tags
Definition json.hpp:9860
@ store
store tags as binary type
Definition json.hpp:9861
@ error
throw a parse_error exception in case of a tag
Definition json.hpp:9859
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
Definition json.hpp:3897
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition json.hpp:3323
void concat_into(OutStringType &)
Definition json.hpp:4415
constexpr bool value_in_range_of(T val)
Definition json.hpp:4300
value_t
the JSON type enumeration
Definition json.hpp:2997
@ null
null value
Definition json.hpp:2998
@ number_integer
number value (signed integer)
Definition json.hpp:3003
@ boolean
boolean value
Definition json.hpp:3002
@ discarded
discarded by the parser callback function
Definition json.hpp:3007
@ binary
binary array (ordered collection of bytes)
Definition json.hpp:3006
@ object
object (unordered set of name/value pairs)
Definition json.hpp:2999
@ string
string value
Definition json.hpp:3001
@ number_float
number value (floating-point)
Definition json.hpp:3005
@ number_unsigned
number value (unsigned integer)
Definition json.hpp:3004
@ array
array (ordered collection of values)
Definition json.hpp:3000
decltype(T::from_json(std::declval< Args >()...)) from_json_function
Definition json.hpp:3646
conjunction< std::is_signed< Types >... > all_signed
Definition json.hpp:4215
constexpr std::size_t unknown_size()
Definition json.hpp:8837
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
Definition json.hpp:5160
StringType to_string(std::size_t value)
Definition json.hpp:5477
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition json.hpp:6364
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
Definition json.hpp:9715
void unescape(StringType &s)
string unescaping as described in RFC 6901 (Sect. 4)
Definition json.hpp:3129
typename make_void< Ts... >::type void_t
Definition json.hpp:266
std::size_t combine(std::size_t seed, std::size_t h) noexcept
Definition json.hpp:6346
decltype(std::declval< T & >().parse_error( std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
Definition json.hpp:9753
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition json.hpp:3026
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition json.hpp:6913
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
Definition json.hpp:3894
typename T::iterator_category iterator_category_t
Definition json.hpp:3640
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
Definition json.hpp:14542
is_c_string< uncvref_t< T > > is_c_string_uncvref
Definition json.hpp:4334
error_handler_t
how to treat decoding errors
Definition json.hpp:18817
@ strict
throw a type_error exception in case of invalid UTF-8
Definition json.hpp:18818
@ ignore
ignore invalid UTF-8 sequences
Definition json.hpp:18820
@ replace
replace invalid UTF-8 sequences with U+FFFD
Definition json.hpp:18819
std::size_t concat_length()
Definition json.hpp:4384
std::integral_constant< bool, Value > bool_constant
Definition json.hpp:4306
decltype(input_adapter(std::declval< std::string >())) string_input_adapter_type
Definition json.hpp:6953
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition json.hpp:3205
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
Definition json.hpp:4857
typename T::key_compare detect_key_compare
Definition json.hpp:3706
void to_json(BasicJsonType &j, T b) noexcept
Definition json.hpp:5965
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition json.hpp:4886
integer_sequence< size_t, Ints... > index_sequence
Definition json.hpp:3261
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
Definition json.hpp:323
is_specialization_of<::nlohmann::json_pointer, uncvref_t< T > > is_json_pointer
Definition json.hpp:4123
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
Definition json.hpp:4431
decltype(std::declval< T & >().end_array()) end_array_function_t
Definition json.hpp:9750
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
Definition json.hpp:5260
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
Definition json.hpp:4437
typename T::key_type key_type_t
Definition json.hpp:3625
typename T::reference reference_t
Definition json.hpp:3637
typename T::is_transparent detect_is_transparent
Definition json.hpp:4136
bjdata_version_t
how to encode BJData
Definition json.hpp:15825
@ draft3
Definition json.hpp:15827
@ draft2
Definition json.hpp:15826
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
Definition json.hpp:4428
typename T::mapped_type mapped_type_t
Definition json.hpp:3622
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
Definition json.hpp:4425
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
Definition json.hpp:3114
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
Definition json.hpp:9727
decltype(std::declval< T >().template get< U >()) get_template_function
Definition json.hpp:3649
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
Definition json.hpp:9719
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
Definition json.hpp:12961
Definition json.hpp:25278
Definition json.hpp:25276
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition json.hpp:25351
namespace for Niels Lohmann
Definition json.hpp:6175
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
Definition json.hpp:6199
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
Definition json.hpp:6189
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
Definition json.hpp:6179
typename BasicJsonType::object_t object_t
Definition json.hpp:3715
typename BasicJsonType::default_object_comparator_t object_comparator_t
Definition json.hpp:3716
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
Definition json.hpp:3717
signed char char_type
Definition json.hpp:3761
static constexpr int_type eof() noexcept
Definition json.hpp:3775
uint64_t int_type
Definition json.hpp:3762
static char_type to_char_type(int_type i) noexcept
Definition json.hpp:3770
static int_type to_int_type(char_type c) noexcept
Definition json.hpp:3765
static char_type to_char_type(int_type i) noexcept
Definition json.hpp:3746
static constexpr int_type eof() noexcept
Definition json.hpp:3751
unsigned char char_type
Definition json.hpp:3737
uint64_t int_type
Definition json.hpp:3738
static int_type to_int_type(char_type c) noexcept
Definition json.hpp:3741
std::true_type value_t
Definition json.hpp:300
Op< Args... > type
Definition json.hpp:301
std::false_type value_t
Definition json.hpp:293
Default type
Definition json.hpp:294
Definition json.hpp:17848
diyfp w
Definition json.hpp:17849
diyfp minus
Definition json.hpp:17850
diyfp plus
Definition json.hpp:17851
Definition json.hpp:17987
std::uint64_t f
Definition json.hpp:17988
int e
Definition json.hpp:17989
int k
Definition json.hpp:17990
Definition json.hpp:17730
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
Definition json.hpp:17754
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
Definition json.hpp:17836
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
Definition json.hpp:17819
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
Definition json.hpp:17742
constexpr diyfp(std::uint64_t f_, int e_) noexcept
Definition json.hpp:17736
static constexpr int kPrecision
Definition json.hpp:17731
std::uint64_t f
Definition json.hpp:17733
int e
Definition json.hpp:17734
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
Definition json.hpp:5874
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
Definition json.hpp:5849
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
Definition json.hpp:5839
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
Definition json.hpp:5861
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
Definition json.hpp:5890
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
Definition json.hpp:5778
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
Definition json.hpp:5787
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
Definition json.hpp:5732
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
Definition json.hpp:5800
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
Definition json.hpp:5826
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
Definition json.hpp:5813
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
Definition json.hpp:5909
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
Definition json.hpp:5930
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
Definition json.hpp:5919
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
Definition json.hpp:5754
static void construct(BasicJsonType &j, const CompatibleStringType &str)
Definition json.hpp:5765
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
Definition json.hpp:5745
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
Definition json.hpp:5371
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3668
static constexpr bool value
Definition json.hpp:3670
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3683
static constexpr bool value
Definition json.hpp:3685
static constexpr bool value
Definition json.hpp:3700
typename BasicJsonType::template json_serializer< T, void > serializer
Definition json.hpp:3698
T value_type
Definition json.hpp:3248
static constexpr std::size_t size() noexcept
Definition json.hpp:3249
an iterator value
Definition json.hpp:13591
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition json.hpp:13595
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition json.hpp:13597
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition json.hpp:13593
static constexpr bool value
Definition json.hpp:4003
static constexpr auto value
Definition json.hpp:4071
std::numeric_limits< RealIntegerType > RealLimits
Definition json.hpp:4068
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
Definition json.hpp:4069
typename BasicJsonType::object_t object_t
Definition json.hpp:3919
static constexpr bool value
Definition json.hpp:3922
static constexpr auto value
Definition json.hpp:3969
static constexpr bool value
Definition json.hpp:4091
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
Definition json.hpp:4040
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value static constexpr bool value
Definition json.hpp:4042
typename BasicJsonType::object_t object_t
Definition json.hpp:3943
static constexpr bool value
Definition json.hpp:3945
ConstructibleStringType laundered_type
Definition json.hpp:3980
static constexpr auto value
Definition json.hpp:3983
static constexpr bool value
Definition json.hpp:3662
typename std::iterator_traits< T >::value_type value_type
Definition json.hpp:6890
static constexpr auto value
Definition json.hpp:3866
char x[2]
Definition json.hpp:4189
@ value
Definition json.hpp:4195
static one test(decltype(&C::capacity))
char one
Definition json.hpp:4185
static constexpr bool value
Definition json.hpp:3890
static constexpr bool value
Definition json.hpp:9772
T value_type
Definition json.hpp:3430
T * pointer
Definition json.hpp:3432
ptrdiff_t difference_type
Definition json.hpp:3431
T & reference
Definition json.hpp:3433
std::random_access_iterator_tag iterator_category
Definition json.hpp:3429
typename It::iterator_category iterator_category
Definition json.hpp:3410
typename It::difference_type difference_type
Definition json.hpp:3406
typename It::value_type value_type
Definition json.hpp:3407
typename It::reference reference
Definition json.hpp:3409
typename It::pointer pointer
Definition json.hpp:3408
Default base class of the basic_json class.
Definition json.hpp:14539
void type
Definition json.hpp:264
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete
abstract output adapter interface
Definition json.hpp:15698
output_adapter_protocol(const output_adapter_protocol &)=default
virtual ~output_adapter_protocol()=default
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
output_adapter_protocol()=default
virtual void write_characters(const CharType *s, std::size_t length)=0
struct to capture the start position of the current token
Definition json.hpp:3160
std::size_t chars_read_current_line
the number of characters read in the current line
Definition json.hpp:3164
std::size_t lines_read
the number of lines read
Definition json.hpp:3166
std::size_t chars_read_total
the total number of characters read
Definition json.hpp:3162
static JSON_INLINE_VARIABLE constexpr T value
Definition json.hpp:3337
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
Definition json.hpp:6144
integer_sequence< T, Ints...,(Ints+SeqSize)... > type
Definition json.hpp:3273
integer_sequence< T, Ints...,(Ints+SeqSize)..., 2 *SeqSize > type
Definition json.hpp:3279
integer_sequence< T > type
Definition json.hpp:3294
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
Definition json.hpp:3287
static constexpr bool test(T val)
Definition json.hpp:4284
static constexpr bool test(T)
Definition json.hpp:4293
static constexpr bool test(T val)
Definition json.hpp:4238
static constexpr bool test(T val)
Definition json.hpp:4258
static constexpr bool test(T val)
Definition json.hpp:4248
static constexpr bool test(T val)
Definition json.hpp:4268
SAX interface.
Definition json.hpp:8722
virtual bool binary(binary_t &val)=0
a binary value was read
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
virtual bool key(string_t &val)=0
an object key was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
typename BasicJsonType::number_integer_t number_integer_t
Definition json.hpp:8723
typename BasicJsonType::string_t string_t
Definition json.hpp:8726
virtual bool end_array()=0
the end of an array was read
json_sax(const json_sax &)=default
virtual bool boolean(bool val)=0
a boolean value was read
virtual bool end_object()=0
the end of an object was read
typename BasicJsonType::number_float_t number_float_t
Definition json.hpp:8725
virtual bool null()=0
a null value was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition json.hpp:8724
json_sax(json_sax &&) noexcept=default
typename BasicJsonType::binary_t binary_t
Definition json.hpp:8727
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
a minimal map-like container that preserves insertion order
Definition json.hpp:19799
std::vector< std::pair< const Key, T >, Allocator > Container
Definition json.hpp:19802
std::pair< iterator, bool > insert(value_type &&value)
Definition json.hpp:20093
typename Container::value_type value_type
Definition json.hpp:19806
std::equal_to< Key > key_compare
Definition json.hpp:19810
iterator erase(iterator pos)
Definition json.hpp:19971
T mapped_type
Definition json.hpp:19801
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
Definition json.hpp:19816
T & operator[](KeyType &&key)
Definition json.hpp:19858
typename Container::iterator iterator
Definition json.hpp:19803
const T & at(KeyType &&key) const
Definition json.hpp:19918
T & at(KeyType &&key)
Definition json.hpp:19890
const T & operator[](KeyType &&key) const
Definition json.hpp:19870
iterator find(const key_type &key)
Definition json.hpp:20055
iterator erase(iterator first, iterator last)
Definition json.hpp:19976
const T & at(const key_type &key) const
Definition json.hpp:19903
const_iterator find(const key_type &key) const
Definition json.hpp:20081
T & operator[](const key_type &key)
Definition json.hpp:19851
size_type erase(KeyType &&key)
Definition json.hpp:19952
typename Container::size_type size_type
Definition json.hpp:19805
ordered_map() noexcept(noexcept(Container()))
Definition json.hpp:19815
void insert(InputIt first, InputIt last)
Definition json.hpp:20116
size_type count(const key_type &key) const
Definition json.hpp:20029
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
Definition json.hpp:19838
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
Definition json.hpp:20112
size_type erase(const key_type &key)
Definition json.hpp:19931
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
Definition json.hpp:19820
std::pair< iterator, bool > insert(const value_type &value)
Definition json.hpp:20098
size_type count(KeyType &&key) const
Definition json.hpp:20043
Key key_type
Definition json.hpp:19800
ordered_map(It first, It last, const Allocator &alloc=Allocator())
Definition json.hpp:19818
const T & operator[](const key_type &key) const
Definition json.hpp:19863
iterator find(KeyType &&key)
Definition json.hpp:20069
T & at(const key_type &key)
Definition json.hpp:19875
typename Container::const_iterator const_iterator
Definition json.hpp:19804
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
Definition json.hpp:19823
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
Definition json.hpp:25320
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition json.hpp:25334
nlohmann::json json
Definition tiingo_client.cpp:16